on master help sign in
Merge pull request #3741 from lpil/Control.Pipeline

Add Control.Pipeline (|>, <|)

commit4bbe9c50082869753d210b5ff6374e01e8dfb3b4 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateFri 14 Apr 2017, 11:55 (10 years ago) parentc68cd26a6be726
1 file changed+26
libs/contrib/Control/Pipeline.idr+26
libs/contrib/Control/Pipeline.idrnew file+26
@@ -0,0 +1,26 @@
1+module Control.Pipeline
2+
3+infixl 9 |>
4+infixr 0 <|
5+
6+%access public export
7+
8+
9+||| Pipeline style function application, useful for chaining
10+||| functions into a series of transformations, reading top
11+||| to bottom.
12+|||
13+||| ```idris example
14+||| [[1], [2], [3]] |> join |> map (* 2)
15+||| ```
16+(|>) : a -> (a -> b) -> b
17+a |> f = f a
18+
19+
20+||| Backwards pipeline style function application, similar to $.
21+|||
22+||| ```idris example
23+||| unpack <| "hello" ++ "world"
24+||| ```
25+(<|) : (a -> b) -> a -> b
26+f <| a = f a