mirror of
https://github.com/rowtype-yoga/purescript-fallback.git
synced 2024-11-29 01:24:29 +03:00
Idris-style fallback for purescript do comprehensions ⚡️
.github/workflows | ||
src/Fallback | ||
test | ||
.gitignore | ||
bower.json | ||
CHANGELOG.md | ||
LICENSE | ||
package.json | ||
packages.dhall | ||
README.md | ||
spago.dhall | ||
test.dhall |
purescript-fallback
Idris-style fallback for do comprehensions.
purescript-fallback
allows you to short-circuit a do-comprehension.
Installation
spago install fallback
Usage
withFallback do
i :: String <- Nothing |> const (Just 0)
result <- Int.fromString i |> const (Just 1)
pure result
-- Just 0
withFallback do
i :: String <- Just "abc" |> const (Just 0)
result <- Int.fromString i |> const (Just 1)
pure result
-- Just 1
withFallback do
i :: String <- Just "10" |> const (Just 0)
result <- Int.fromString i |> const (Just 1)
pure result
-- Just 10