Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
```