Created
August 4, 2013 16:22
-
-
Save vlastachu/6150873 to your computer and use it in GitHub Desktop.
operator to change function and argument order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- such functionality already exist in Control.Lens in '&' operator | |
-- '|>' alreade used in Data.Sequence | |
module Main where | |
(|>) :: a -> (a -> b) -> b | |
(|>) a fun = fun a | |
infixl 1 |> | |
main = print $ [1..10] |> map (*2) |> filter (>5) |> foldr1 (+) | |
-- have idea to improve that function: print $ [1..10] |> map (*2) |> filter (>5) |> foldr1 (+) | |
-- this functionality was wroten because it easear to read: print list from 1 to 10 which mapped filtered etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment