@@ -0,0 +1,39 @@
1+||| Combinators that are thought to be at least situationally useful, mostly for
2+||| tacit (or point-free) programming. "To Mock a Mockingbird" refers to the book
3+||| "To Mock a Mockingbird and Other Logic Puzzles: Including an Amazing Adventure
4+||| in Combinatory Logic", by Raymond Smullyan (which the author of this module
5+||| hasn't actually read). See
6+||| http://www.angelfire.com/tx4/cus/combinator/birds.html and
7+||| https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
8+||| an (incomplete?) list of birds introduced. Also includes some operations defined
9+||| over Arrows.
10+
11+module Data.Combinators
12+
13+%default total
14+%access public export
15+
16+||| Psi combinator - psi bird (?) - Haskell on.
17+on : (b -> b -> c) -> (a -> b) -> (a -> a -> c)
18+on f g x y = g x `f` g y
19+
20+
21+infixl 9 ...
22+||| Blackbird, as named in "To Mock a Mockingbird". This is like
23+||| function composition, but second function takes two arguments. See the talk
24+||| "Point-Free or Die: Tacit Programming in Haskell and Beyond" by Amar Shah
25+||| (https://youtu.be/seVSlKazsNk).
26+(...) : (c -> d) -> (a -> b -> c) -> (a -> b -> d)
27+(...) = (.) . (.)
28+
29+||| Warbler, as named in "To Mock a Mockingbird".
30+||| See http://code.jsoftware.com/wiki/Vocabulary/tilde
31+||| Equivalent to `join` on the Reader monad (`(->) e` in Haskell)
32+reflex : (a -> a -> b) -> (a -> b)
33+reflex f x = f x x
34+
35+||| Phoenix, according to Data.Aviary.
36+||| See http://code.jsoftware.com/wiki/Vocabulary/fork.
37+||| Equivalent to `liftA2` on the Reader monad (`(->) e` in Haskell)
38+fork2 : (b -> c -> d) -> (a -> b) -> (a -> c) -> (a -> d)
39+fork2 f g h x = f (g x) (h x)