Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created January 21, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/5685f5d888724fe3017c to your computer and use it in GitHub Desktop.
Save shigemk2/5685f5d888724fe3017c to your computer and use it in GitHub Desktop.
flip' :: (a -> b -> c) -> (b -> a -> c)
flip' f = g
where g x y = f y x
flip'' :: (a -> b -> c) -> b -> a -> c
-- flip'' :: a -> b -> c -> b -> a -> c -- このように書くとエラー
flip'' f x y = f y x
main = do
print $ flip' map [1..5] (* 2)
print $ flip'' map [1..5] (* 3)
print $ flip'' zip [1..5] "hello"
print $ flip'' zip "hello" [1..5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment