Skip to content

Instantly share code, notes, and snippets.

@lepoetemaudit
Created November 29, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lepoetemaudit/103ea48a363d2c49d671a156d8f9558d to your computer and use it in GitHub Desktop.
Save lepoetemaudit/103ea48a363d2c49d671a156d8f9558d to your computer and use it in GitHub Desktop.
Demonstrating infix vs pipe and function approach in Elm
import Html exposing (text)
(>>=) x y = Result.andThen y x
-- We need
r = Ok "hello"
|> Result.andThen (\x -> Ok " world"
|> Result.andThen (\y -> Ok (x ++ y)))
r2 = Ok "hello"
>>= \x -> Ok "world"
>>= \y -> Ok (x ++ y)
main =
text <| (toString r) ++ " == " ++ (toString r2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment