git.iko.soy/rowtype-yoga/purescript-fallback
on main help sign in
33 lines 637 B history raw
1# purescript-fallback
3Idris-style fallback for do comprehensions.
5`purescript-fallback` allows you to short-circuit a do-comprehension.
7## Installation
9```bash
10spago install fallback
11```
13## Usage
15```purescript
16withFallback do
17 i :: String <- Nothing |> const (Just 0)
18 result <- Int.fromString i |> const (Just 1)
19 pure result
20-- Just 0
22withFallback do
23 i :: String <- Just "abc" |> const (Just 0)
24 result <- Int.fromString i |> const (Just 1)
25 pure result
26-- Just 1
28withFallback do
29 i :: String <- Just "10" |> const (Just 0)
30 result <- Int.fromString i |> const (Just 1)
31 pure result
32-- Just 10
33```