Last active
November 25, 2022 14:33
-
-
Save lpil/98589aaca3b09a3c7ce92b4a1b1d521a to your computer and use it in GitHub Desktop.
An example of the trailing lambda pattern in Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (text) | |
main = | |
let result = | |
bind readNumber <| \x -> | |
bind readNumber <| \y -> | |
bind readNumber <| \z -> | |
Ok (x + y + z) | |
in | |
text (Debug.toString result) | |
bind result f = | |
case result of | |
Ok x -> f x | |
Err x -> Err x | |
readNumber = Ok 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment