Skip to content

Instantly share code, notes, and snippets.

@lpil
Last active November 25, 2022 14:33
Show Gist options
  • Save lpil/98589aaca3b09a3c7ce92b4a1b1d521a to your computer and use it in GitHub Desktop.
Save lpil/98589aaca3b09a3c7ce92b4a1b1d521a to your computer and use it in GitHub Desktop.
An example of the trailing lambda pattern in Elm
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