Skip to content

Instantly share code, notes, and snippets.

@YusukeHosonuma
Created May 8, 2016 14:27
Show Gist options
  • Save YusukeHosonuma/03d21feb440165c814a6ca81b5162b20 to your computer and use it in GitHub Desktop.
Save YusukeHosonuma/03d21feb440165c814a6ca81b5162b20 to your computer and use it in GitHub Desktop.
Haskell - UNIX's pipe like style for functional composition
-- | すごいHaskell楽しく学ぼう版
-- replicate 2 . product . map (*3) $ zipWith max [1, 2] [4, 5]
--
-- | オリジナルパイプ版(UNIXライク)
-- zipWith max [1, 2] [4, 5] > (map (*3) | product | replicate 2)
--
(|) :: (a -> b) -> (b -> c) -> (a -> c)
g | f = \x -> f $ g x
(>) :: a -> (a -> b) -> b
x > f = f x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment