Created
May 30, 2018 18:08
-
-
Save JoelQ/9a3a33ef77f4e565e6f92627b3001743 to your computer and use it in GitHub Desktop.
A look at mapN functions in Elm. The `map0` function is just the constructor function! Haskell folks would call this pure/return.
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
-- Maybe | |
map2 f v1 v2 = Just f |> andMap v1 |> andMap v2 | |
map f v1 = Just f |> andMap v1 | |
map0 f = Just f | |
-- List | |
map2 f v1 v2 = singleton f |> andMap v1 |> andMap v2 | |
map f v1 = singleton f |> andMap v1 | |
map0 f = singleton f | |
-- Json.Decode.Decoder | |
map2 f v1 v2 = succeed f |> andMap v1 |> andMap v2 | |
map f v1 = succeed f |> andMap v1 | |
map0 f = succeed f | |
-- Random.Generator | |
map2 f v1 v2 = constant f |> andMap v1 |> andMap v2 | |
map f v1 = constant f |> andMap v1 | |
map0 f = constant f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment