Skip to content

Instantly share code, notes, and snippets.

@boombang
Created October 16, 2019 06:41
Show Gist options
  • Save boombang/fb380b6b306bf23ec53acf808db43d8f to your computer and use it in GitHub Desktop.
Save boombang/fb380b6b306bf23ec53acf808db43d8f to your computer and use it in GitHub Desktop.
-- Piping: Chaining functions
foo =
Html.text (String.fromInt (add 5 (multiply 10 (divide 30 10))))
-- x |> f = f x
baz =
divide 30 10
|> multiply 10
|> add 5
|> String.fromInt
|> Html.text
-- Function composition
-- String.words : String -> List String
-- List.length : List a -> Int
-- (>>) : (a -> b) -> (b -> c) -> a -> c
wordCount = String.words >> List.length
-- wordCount : String -> Int
result = wordCount "use Elm and prosper"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment