Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinwoo/purescript-kushiyaki
A library for PureScript 0.12 using Record-Format to parse urls with a template.
https://github.com/justinwoo/purescript-kushiyaki
parsing purescript type-level url
Last synced: about 2 months ago
JSON representation
A library for PureScript 0.12 using Record-Format to parse urls with a template.
- Host: GitHub
- URL: https://github.com/justinwoo/purescript-kushiyaki
- Owner: justinwoo
- License: mit
- Created: 2018-05-02T21:44:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-24T12:17:25.000Z (over 6 years ago)
- Last Synced: 2024-10-11T23:44:39.794Z (2 months ago)
- Topics: parsing, purescript, type-level, url
- Language: PureScript
- Homepage:
- Size: 7.81 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureScript-Kushiyaki
A library for PureScript 0.12 using [Record-Format](https://github.com/kcsongor/purescript-record-format) to parse urls with a template.
![](https://i.imgur.com/OmQPvvo.jpg)
## Usage
See
```hs
main :: Effect Unit
main = do
let (parseURL'
-- inferred type:
:: String -> Either String { name :: String, age :: String})
= parseURL (SProxy :: SProxy "/hello/{name}/{age}")
let parsed = parseURL' "/hello/Bill/12"
case parsed of
Left e -> do
log $ "didn't work: " <> e
assert $ 1 == 2
Right r -> do
assert $ r.name == "Bill"
assert $ r.age == "12"-- let (parseURL2'
-- -- inferred type:
-- :: String -> Either String { name :: String, age :: Int })
let parseURL2'
= parseURL (SProxy :: SProxy "/hello/{name:String}/{age:Int}")
let parsed2 = parseURL2' "/hello/Bill/12"
case parsed2 of
Left e -> do
log $ "didn't work: " <> e
assert $ 1 == 2
Right r -> do
assert $ r.name == "Bill"
assert $ r.age == 12
```