Skip to content

Instantly share code, notes, and snippets.

@vlastachu
Created August 4, 2013 16:22
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 vlastachu/6150873 to your computer and use it in GitHub Desktop.
Save vlastachu/6150873 to your computer and use it in GitHub Desktop.
operator to change function and argument order
-- 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