Created
November 29, 2016 16:08
-
-
Save lepoetemaudit/103ea48a363d2c49d671a156d8f9558d to your computer and use it in GitHub Desktop.
Demonstrating infix vs pipe and function approach 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) | |
(>>=) 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