first commit
commitc26d87f68df406b87c1672ffc58e09934d97e0d6
authorsigma-andex <77549848+sigma-andex@users.noreply.github.com>
dateTue 5 Jul 2022, 17:06 (4 years ago)
README.mdnew file+31
@@ -0,0 +1,31 @@
1+# purescript-fallback
2+
3+Idris-style fallback for do comprehensions.
4+
5+## installation
6+
7+```bash
8+spago install fallback
9+```
10+
11+## Usage
12+
13+```purescript
14+withFallback do
15+ i :: String <- Nothing |> const (Just 0)
16+ result <- Int.fromString i |> const (Just 1)
17+ pure result
18+-- Just 0
19+
20+withFallback do
21+ i :: String <- Just "abc" |> const (Just 0)
22+ result <- Int.fromString i |> const (Just 1)
23+ pure result
24+-- Just 1
25+
26+withFallback do
27+ i :: String <- Just "10" |> const (Just 0)
28+ result <- Int.fromString i |> const (Just 1)
29+ pure result
30+-- Just 10
31+```