Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinwoo/purescript-sijidou
A library for matching a string into a record of functions of statically known Symbol proxies.
https://github.com/justinwoo/purescript-sijidou
purescript
Last synced: about 2 months ago
JSON representation
A library for matching a string into a record of functions of statically known Symbol proxies.
- Host: GitHub
- URL: https://github.com/justinwoo/purescript-sijidou
- Owner: justinwoo
- License: mit
- Created: 2018-10-24T18:57:28.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-13T07:28:38.000Z (about 5 years ago)
- Last Synced: 2024-10-11T23:44:39.760Z (2 months ago)
- Topics: purescript
- Language: PureScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureScript-Sijidou
A library for matching a string into a record of functions of statically known Symbol proxies.
Named after 干煸四季豆 (gan bian sijidou), aka what people call "that string bean dish I tried once in a weird Chinese restaurant".
![](https://i.imgur.com/9iWaGD5.jpg)
## Example
```purs
main = do
let
fruits =
{ apple: "great"
, banana: "good"
}key1 = "apple"
key2 = "durian"
key3 = "banana"matchString :: String -> Maybe String
matchString = S.matchString
{ apple: \k -> Record.get k fruits
, banana: \k -> Record.get k fruits
}result1 = matchString key1
result2 = matchString key2
result3 = matchString key3assertEqual { actual: result1, expected: Just "great" }
assertEqual { actual: result2, expected: Nothing }
assertEqual { actual: result3, expected: Just "good" }
```