Skip to content

Instantly share code, notes, and snippets.

@Irio
Created July 9, 2014 18:10
Show Gist options
  • Save Irio/430a457be0a5d8ab580d to your computer and use it in GitHub Desktop.
Save Irio/430a457be0a5d8ab580d to your computer and use it in GitHub Desktop.
Function composition and application in Haskell
sumArgs :: Integer -> Integer -> Integer
sumArgs x y = x + y
times10 :: Integer -> Integer
times10 x = x * 10
-- times10 . sumArgs 1 2 will become
-- > let composed = \x -> times10 (sumArgs x)
-- > composed 1 2
-- error!
--
-- times10 . sumArgs 1 $ 2 will become
-- > let composed = \x -> times10 ((sumArgs x) 2)
-- > composed 1
-- 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment