Idris-style fallback for purescript do comprehensions
Go to file
2022-07-06 10:53:26 +01:00
.github/workflows Minor readme update and added ci.yml 2022-07-05 17:10:52 +01:00
src/Fallback Add function comments 2022-07-06 10:05:50 +01:00
test Initial commit 2022-07-05 17:06:59 +01:00
.gitignore Initial commit 2022-07-05 17:06:59 +01:00
bower.json Add bower.json 2022-07-06 10:07:49 +01:00
CHANGELOG.md Initial commit 2022-07-05 17:06:59 +01:00
LICENSE Initial commit 2022-07-05 17:06:59 +01:00
package.json Add meta information 2022-07-05 17:14:54 +01:00
packages.dhall Format .dhall files 2022-07-06 10:53:26 +01:00
README.md Minor readme update and added ci.yml 2022-07-05 17:10:52 +01:00
spago.dhall Format .dhall files 2022-07-06 10:53:26 +01:00
test.dhall Initial commit 2022-07-05 17:06:59 +01:00

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