Skip to content

Instantly share code, notes, and snippets.

@programatt
Created January 22, 2014 02:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programatt/8552689 to your computer and use it in GitHub Desktop.
Save programatt/8552689 to your computer and use it in GitHub Desktop.
Haskell Function Composition with multiple arguments example
f :: [Bool] -> Bool
f = and
g :: (Eq a) => ([a],[a]) -> [Bool]
g = uncurry $ zipWith (==)
h :: (Eq a) => ([a],[a]) -> Bool
h = f . g
f' :: [Bool] -> Bool
f' = and
g' :: (Eq a) => [a] -> [a] -> [Bool]
g' = zipWith (==)
h' :: (Eq a) => [a] -> [a] -> Bool
h' xs ys = (f' . uncurry g')(xs,ys)
main :: IO ()
main = do
print $ h ([1,2,3],[1,2,3])
print $ h' [1,2,3] [1,2,3]
@Unisay
Copy link

Unisay commented May 4, 2017

h'' :: (Eq a) => [a] -> [a] -> Bool
h'' = (f' .) . g'

dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = (.).(.) -- look into my eyes!

h''' :: (Eq a) => [a] -> [a] -> Bool
h''' = f' `dot` g'

;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment