-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Combinator birds. -- -- A catalogue of the combinator birds (Data.Aviary.Birds) - this module -- is intended more for illustration than utility. -- -- (Data.Aviary.Functional) operations from Applicative, Monad etc. with -- their types specialized to the function type. This might be usefulfor -- bird-watching i.e. spotting instances where an Applicative, -- Monad or whatever operation corresponds to a combinator bird. Again -- this module is not intended for actual use. -- -- Plus a smaller set (Data.Aviary) intended to be useful, collecting -- combinators that have already escaped (published elsewhere) but -- aren't in Data.Function, along with some personal favourites. -- -- Changelog: -- --
    --
  1. 2.2 added Data.Aviary.Functional - Applicative, Monad etc. -- signatures specialized to the function type.
  2. --
  3. 2.1 added dup and the combiner variants of -- cardinal-prime.
  4. --
  5. 2.0 added Haddock docs for (##).
  6. --
@package data-aviary @version 0.2.2 -- | Functor, Applicative, Monad operations specialized to the -- functional type. -- -- This is for reference (obviously) and is not intended for use. module Data.Aviary.Functional fmap :: (a -> b) -> (r -> a) -> (r -> b) (<$>) :: (a -> b) -> (r -> a) -> (r -> b) (<$) :: a -> (r -> b) -> (r -> a) pure :: a -> (r -> a) (<*>) :: (r -> a -> b) -> (r -> a) -> (r -> b) (*>) :: (r -> a) -> (r -> b) -> (r -> b) (<*) :: (r -> a) -> (r -> b) -> (r -> a) (<**>) :: (r -> a) -> (r -> a -> b) -> (r -> b) liftA :: (a -> b) -> (r -> a) -> (r -> b) liftA2 :: (a -> b -> c) -> (r -> a) -> (r -> b) -> (r -> c) liftA3 :: (a -> b -> c -> d) -> (r -> a) -> (r -> b) -> (r -> c) -> (r -> d) id :: a -> a (.) :: (b -> c) -> (a -> b) -> (a -> c) (<<<) :: (b -> c) -> (a -> b) -> (a -> c) (>>>) :: (a -> b) -> (b -> c) -> (a -> c) (>>=) :: (r -> a) -> (a -> r -> b) -> (r -> b) (>>) :: (r -> a) -> (r -> b) -> (r -> b) return :: a -> (r -> a) fail :: String -> (r -> a) mapM :: (a -> r -> b) -> [a] -> r -> [b] mapM_ :: (a -> r -> b) -> [a] -> r -> () forM :: [a] -> (a -> r -> b) -> r -> [b] forM_ :: [a] -> (a -> r -> b) -> r -> () sequence :: [r -> a] -> r -> [a] sequence_ :: [r -> a] -> r -> () (=<<) :: (a -> r -> b) -> (r -> a) -> r -> b (>=>) :: (a -> r -> b) -> (b -> r -> c) -> a -> r -> c (<=<) :: (b -> r -> c) -> (a -> r -> b) -> a -> r -> c forever :: (r -> a) -> (r -> b) join :: (r -> (r -> a)) -> r -> a filterM :: (a -> r -> Bool) -> [a] -> r -> [a] mapAndUnzipM :: (a -> r -> (b, c)) -> [a] -> r -> ([b], [c]) zipWithM :: (a -> b -> r -> c) -> [a] -> [b] -> r -> [c] zipWithM_ :: (a -> b -> r -> c) -> [a] -> [b] -> r -> () foldM :: (a -> b -> r -> a) -> a -> [b] -> r -> a foldM_ :: (a -> b -> r -> a) -> a -> [b] -> r -> () replicateM :: Int -> (r -> a) -> r -> [a] replicateM_ :: Int -> (r -> a) -> r -> () when :: Bool -> (r -> ()) -> r -> () unless :: Bool -> (r -> ()) -> r -> () liftM :: (a -> b) -> (r -> a) -> r -> b liftM2 :: (a -> b -> c) -> (r -> a) -> (r -> b) -> r -> c liftM3 :: (a -> b -> c -> d) -> (r -> a) -> (r -> b) -> (r -> c) -> r -> d liftM4 :: (a -> b -> c -> d -> e) -> (r -> a) -> (r -> b) -> (r -> c) -> (r -> d) -> r -> e liftM5 :: (a -> b -> c -> d -> e -> f) -> (r -> a) -> (r -> b) -> (r -> c) -> (r -> d) -> (r -> e) -> r -> f ap :: (r -> a -> b) -> (r -> a) -> r -> b arr :: (b -> c) -> b -> c first :: (b -> c) -> (b, d) -> (c, d) second :: (b -> c) -> (d, b) -> (d, c) (***) :: (b -> c) -> (b' -> c') -> (b, b') -> (c, c') (&&&) :: (b -> c) -> (b -> c') -> b -> (c, c') returnA :: b -> b (^>>) :: (b -> c) -> (c -> d) -> (b -> d) (>>^) :: (b -> c) -> (c -> d) -> (b -> d) (<<^) :: (c -> d) -> (b -> c) -> (b -> d) (^<<) :: (c -> d) -> (b -> c) -> (b -> d) left :: (b -> c) -> (Either b d) -> (Either c d) right :: (b -> c) -> (Either d b) -> (Either d c) (+++) :: (b -> c) -> (b' -> c') -> (Either b b') -> (Either c c') (|||) :: (b -> d) -> (c -> d) -> (Either b c) -> d app :: (b -> c, b) -> c leftApp :: (b -> c) -> (Either b d) -> (Either c d) loop :: ((b, d) -> (c, d)) -> b -> c extract :: (Monoid m) => (m -> a) -> a duplicate :: (Monoid m) => (m -> a) -> m -> (m -> a) extend :: (Monoid m) => ((m -> a) -> b) -> (m -> a) -> m -> b liftW :: (Monoid m) => (a -> b) -> (m -> a) -> m -> b (=>>) :: (Monoid m) => (m -> a) -> ((m -> a) -> b) -> m -> b (.>>) :: (Monoid m) => (m -> a) -> b -> m -> b liftCtx :: (Monoid m) => (a -> b) -> (m -> a) -> b mapW :: (Monoid m) => ((m -> a) -> b) -> (m -> [a]) -> [b] parallelW :: (Monoid m) => (m -> [a]) -> [m -> a] unfoldW :: (Monoid m) => ((m -> b) -> (a, b)) -> (m -> b) -> [a] sequenceW :: (Monoid m) => [(m -> a) -> b] -> (m -> a) -> [b] -- | Bird monickered combinators interdefined. -- -- This module is intended for illustration (the type signatures!) rather -- than utility. -- -- The 'long reach' Turner set { S, K, I, B, C, S', B', C' } -- -- The Joy et al. set { S, I, B, C, J(alt), S', B', C', J(alt)' } module Data.Aviary.BirdsInter -- | I combinator - identity bird / idiot bird - Haskell id. idiot :: a -> a -- | K combinator - kestrel - Haskell const. Corresponds to the -- encoding of true in the lambda calculus. -- -- Not interdefined. kestrel :: a -> b -> a -- | B combinator - bluebird - Haskell (.). bluebird :: (b -> c) -> (a -> b) -> a -> c -- | C combinator - cardinal - Haskell flip. cardinal :: (a -> b -> c) -> b -> a -> c -- | A combinator - apply / applicator - Haskell ($). -- -- Note: the definition here is - C (B B I) I - and not the -- familiar - S (S K) - which as far as Haskell is concerned has -- a different type. -- --
--   (S(SK)) :: ((a -> b) -> a) -> (a -> b) -> a
--   
applicator :: (a -> b) -> a -> b -- | Psi combinator - psi bird (?) - Haskell on. psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c -- | B3 combinator - becard. becard :: (c -> d) -> (b -> c) -> (a -> b) -> a -> d -- | B1 combinator - blackbird - specs oo. blackbird :: (c -> d) -> (a -> b -> c) -> a -> b -> d -- | B' combinator - bluebird prime. bluebird' :: (a -> c -> d) -> a -> (b -> c) -> b -> d -- | B2 combinator - bunting - specs ooo. bunting :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -- | C' combinator - no name. cardinal' :: (c -> a -> d) -> (b -> c) -> a -> b -> d -- | C* combinator - cardinal once removed. cardinalstar :: (a -> c -> b -> d) -> a -> b -> c -> d -- | C** combinator - cardinal twice removed. cardinalstarstar :: (a -> b -> d -> c -> e) -> a -> b -> c -> d -> e -- | D combinator - dove. dove :: (a -> c -> d) -> a -> (b -> c) -> b -> d -- | D1 combinator - dickcissel. dickcissel :: (a -> b -> d -> e) -> a -> b -> (c -> d) -> c -> e -- | D2 combinator - dovekie. dovekie :: (c -> d -> e) -> (a -> c) -> a -> (b -> d) -> b -> e -- | E combinator - eagle. eagle :: (a -> d -> e) -> a -> (b -> c -> d) -> b -> c -> e -- | E ^ - bald eagle. For alphabetical regularity it is somewhat misnamed -- here as eaglebald. eaglebald :: (e -> f -> g) -> (a -> b -> e) -> a -> b -> (c -> d -> f) -> c -> d -> g -- | F combinator - finch. finch :: a -> b -> (b -> a -> c) -> c -- | F* combinator - finch once removed. finchstar :: (c -> b -> a -> d) -> a -> b -> c -> d -- | F** combinator - finch once removed. finchstarstar :: (a -> d -> c -> b -> e) -> a -> b -> c -> d -> e -- | G combinator - goldfinch. goldfinch :: (b -> c -> d) -> (a -> c) -> a -> b -> d -- | H combinator - hummingbird. hummingbird :: (a -> b -> a -> c) -> a -> b -> c -- | I* combinator - identity bird once removed. Alias of -- applicator, Haskell's ($). Type signature idstar :: (a -> b) -> a -> b -- | I** combinator - identity bird twice removed. idstarstar :: (a -> b -> c) -> a -> b -> c -- | Alternative J combinator - this is the J combintor of Joy, -- Rayward-Smith and Burton (see. Antoni Diller 'Compiling Functional -- Languages' page 104). It is not the J - jay combinator of the -- literature. jalt :: (a -> c) -> a -> b -> c -- | J' combinator - from Joy, Rayward-Smith and Burton. See the comment to -- jalt. jalt' :: (a -> b -> d) -> a -> b -> c -> d -- | J combinator - jay. -- -- This is the usual J combinator. jay :: (a -> b -> b) -> a -> b -> a -> b -- | Ki - kite. Corresponds to the encoding of false in the lambda -- calculus. kite :: a -> b -> b -- | O combinator - owl. owl :: ((a -> b) -> a) -> (a -> b) -> b -- | (Big) Phi combinator - phoenix - Haskell liftM2. phoenix :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d -- | Q4 combinator - quacky bird. quacky :: a -> (a -> b) -> (b -> c) -> c -- | Q combinator - queer bird. -- -- Haskell (##) in Peter Thiemann's Wash, reverse composition. queer :: (a -> b) -> (b -> c) -> a -> c -- | Q3 combinator - quirky bird. quirky :: (a -> b) -> a -> (b -> c) -> c -- | Q1 combinator - quixotic bird. quixotic :: (b -> c) -> a -> (a -> b) -> c -- | Q2 combinator - quizzical bird. quizzical :: a -> (b -> c) -> (a -> b) -> c -- | R combinator - robin. robin :: a -> (b -> a -> c) -> b -> c -- | R* combinator - robin once removed. robinstar :: (b -> c -> a -> d) -> a -> b -> c -> d -- | R** combinator - robin twice removed. robinstarstar :: (a -> c -> d -> b -> e) -> a -> b -> c -> d -> e -- | S combinator - starling. -- -- Haskell: Applicative's (<*>) on functions. -- -- Not interdefined. starling :: (a -> b -> c) -> (a -> b) -> a -> c -- | S' combinator - starling prime - Turner's big phi. Haskell: -- Applicative's liftA2 on functions. starling' :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d -- | T combinator - thrush. Haskell (#) in Peter Thiemann's Wash, -- reverse application. thrush :: a -> (a -> b) -> b -- | V combinator - vireo. vireo :: a -> b -> (a -> b -> b) -> b -- | V* combinator - vireo once removed. vireostar :: (b -> a -> b -> d) -> a -> b -> b -> d -- | V** combinator - vireo twice removed. vireostarstar :: (a -> c -> b -> c -> e) -> a -> b -> c -> c -> e -- | W combinator - warbler - elementary duplicator. warbler :: (a -> a -> b) -> a -> b -- | W1 combinator - converse warbler. warbler with the arguments -- reversed. warbler1 :: a -> (a -> a -> b) -> b -- | W* combinator - warbler once removed. warblerstar :: (a -> b -> b -> c) -> a -> b -> c -- | W** combinator - warbler twice removed. warblerstarstar :: (a -> b -> c -> c -> d) -> a -> b -> c -> d -- | Bird monickered combinators -- -- This module is intended for illustration (the type signatures!) rather -- than utility. -- -- The 'long reach' Turner set { S, K, I, B, C, S', B', C' } -- -- The Joy et al. set { S, I, B, C, J(alt), S', B', C', J(alt)' } module Data.Aviary.Birds -- | I combinator - identity bird / idiot bird - Haskell id. idiot :: a -> a -- | K combinator - kestrel - Haskell const. Corresponds to the -- encoding of true in the lambda calculus. kestrel :: a -> b -> a -- | B combinator - bluebird - Haskell (.). bluebird :: (b -> c) -> (a -> b) -> a -> c -- | C combinator - cardinal - Haskell flip. cardinal :: (a -> b -> c) -> b -> a -> c -- | A combinator - apply / applicator - Haskell ($). applicator :: (a -> b) -> a -> b -- | Psi combinator - psi bird (?) - Haskell on. psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c -- | B3 combinator - becard. becard :: (c -> d) -> (b -> c) -> (a -> b) -> a -> d -- | B1 combinator - blackbird - specs oo. blackbird :: (c -> d) -> (a -> b -> c) -> a -> b -> d -- | B' combinator - bluebird prime. bluebird' :: (a -> c -> d) -> a -> (b -> c) -> b -> d -- | B2 combinator - bunting - specs ooo. bunting :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -- | C' combinator - no name. cardinal' :: (c -> a -> d) -> (b -> c) -> a -> b -> d -- | C* combinator - cardinal once removed. cardinalstar :: (a -> c -> b -> d) -> a -> b -> c -> d -- | C** combinator - cardinal twice removed. cardinalstarstar :: (a -> b -> d -> c -> e) -> a -> b -> c -> d -> e -- | D combinator - dove. dove :: (a -> c -> d) -> a -> (b -> c) -> b -> d -- | D1 combinator - dickcissel. dickcissel :: (a -> b -> d -> e) -> a -> b -> (c -> d) -> c -> e -- | D2 combinator - dovekie. dovekie :: (c -> d -> e) -> (a -> c) -> a -> (b -> d) -> b -> e -- | E combinator - eagle. eagle :: (a -> d -> e) -> a -> (b -> c -> d) -> b -> c -> e -- | E ^ - bald eagle. For alphabetical regularity it is somewhat misnamed -- here as eaglebald. eaglebald :: (e -> f -> g) -> (a -> b -> e) -> a -> b -> (c -> d -> f) -> c -> d -> g -- | F combinator - finch. finch :: a -> b -> (b -> a -> c) -> c -- | F* combinator - finch once removed. finchstar :: (c -> b -> a -> d) -> a -> b -> c -> d -- | F** combinator - finch once removed. finchstarstar :: (a -> d -> c -> b -> e) -> a -> b -> c -> d -> e -- | G combinator - goldfinch. goldfinch :: (b -> c -> d) -> (a -> c) -> a -> b -> d -- | H combinator - hummingbird. hummingbird :: (a -> b -> a -> c) -> a -> b -> c -- | I* combinator - identity bird once removed Alias of applicator, -- Haskell's ($). idstar :: (a -> b) -> a -> b -- | I** combinator - identity bird twice removed idstarstar :: (a -> b -> c) -> a -> b -> c -- | Alternative J combinator - this is the J combintor of Joy, -- Rayward-Smith and Burton (see. Antoni Diller 'Compiling Functional -- Languages' page 104). It is not the J - jay combinator of the -- literature. jalt :: (a -> c) -> a -> b -> c -- | J' combinator - from Joy, Rayward-Smith and Burton. See the comment to -- jalt. jalt' :: (a -> b -> d) -> a -> b -> c -> d -- | J combinator - jay. -- -- This is the usual J combinator. jay :: (a -> b -> b) -> a -> b -> a -> b -- | Ki - kite. Corresponds to the encoding of false in the lambda -- calculus. kite :: a -> b -> b -- | O combinator - owl. owl :: ((a -> b) -> a) -> (a -> b) -> b -- | (Big) Phi combinator - phoenix - Haskell liftM2. phoenix :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d -- | Q4 combinator - quacky bird. quacky :: a -> (a -> b) -> (b -> c) -> c -- | Q combinator - queer bird. -- -- Haskell (##) in Peter Thiemann's Wash, reverse composition. queer :: (a -> b) -> (b -> c) -> a -> c -- | Q3 combinator - quirky bird. quirky :: (a -> b) -> a -> (b -> c) -> c -- | Q1 combinator - quixotic bird. quixotic :: (b -> c) -> a -> (a -> b) -> c -- | Q2 combinator - quizzical bird. quizzical :: a -> (b -> c) -> (a -> b) -> c -- | R combinator - robin. robin :: a -> (b -> a -> c) -> b -> c -- | R* combinator - robin once removed. robinstar :: (b -> c -> a -> d) -> a -> b -> c -> d -- | R* combinator - robin twice removed. robinstarstar :: (a -> c -> d -> b -> e) -> a -> b -> c -> d -> e -- | S combinator - starling. -- -- Haskell: Applicative's (<*>) on functions. -- -- Substitution. starling :: (a -> b -> c) -> (a -> b) -> a -> c -- | S' combinator - starling prime - Turner's big phi. Haskell: -- Applicative's liftA2 on functions. starling' :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d -- | T combinator - thrush. Haskell (#) in Peter Thiemann's Wash, -- reverse application. thrush :: a -> (a -> b) -> b -- | V combinator - vireo. vireo :: a -> b -> (a -> b -> c) -> c -- | V* combinator - vireo once removed. vireostar :: (b -> a -> b -> d) -> a -> b -> b -> d -- | V** combinator - vireo twice removed. vireostarstar :: (a -> c -> b -> c -> e) -> a -> b -> c -> c -> e -- | W combinator - warbler - elementary duplicator. warbler :: (a -> a -> b) -> a -> b -- | W1 combinator - converse warbler. warbler with the arguments -- reversed. warbler1 :: a -> (a -> a -> b) -> b -- | W* combinator - warbler once removed. warblerstar :: (a -> b -> b -> c) -> a -> b -> c -- | W** combinator - warbler twice removed. warblerstarstar :: (a -> b -> c -> c -> d) -> a -> b -> c -> d -- | Plainly named combinators -- -- Sometimes permuted to be generally useful... -- -- Note the fixity of (#) and (##) is not yet -- fixed. Some experience needs to be gathered as to whether the -- precendence levels are appropriate. module Data.Aviary -- | T combinator - thrush -- -- Reverse application - the T combinator. Found in Peter Thiemann's WASH -- and the paper 'Client-Side Web Scripting in Haskell' - Erik Meijer, -- Daan Leijen & James Hook. (#) :: a -> (a -> b) -> b -- | Q Combinator - the queer bitd. -- -- Reverse composition - found in Peter Thiemann's WASH. You might perfer -- to use (<<<) from Control.Categoty. (##) :: (a -> b) -> (b -> c) -> a -> c -- | S combinator - subst. Familiar as Applicative's (<*>) -- operator, which itself is fmap: -- -- f (b -> c) -> f b -> f c where f = ((->) a) subst :: (a -> b -> c) -> (a -> b) -> a -> c -- | The big Phi, or Turner's S' combinator. Known to Haskell -- programmers as liftA2 and liftM2 for the Applicative and Monad -- instances of (->). -- --
--   (a1 -> a2 -> r) -> m a1 -> m a2 -> m r where m = ((->) a)
--   
-- -- Taste suggests you may prefer liftA2 especially as bigphi is -- not a great name (calling it s' would take a very useful variable -- name). bigphi :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d -- | A variant of the D2 or dovekie combinator - the argument -- order has been changed to be more satisfying for Haskellers: -- --
--   (appro comb f g) x y
--   
-- --
--   (f x) `comb` (g y)
--   
-- -- on from Data.Function is similar but less general, where the -- two intermediate results are formed by applying the same function to -- the supplied arguments: -- --
--   on = (appro comb f f)
--   
appro :: (c -> d -> e) -> (a -> c) -> (b -> d) -> a -> b -> e -- | dup - duplicator aka the W combinator aka Warbler. -- --
--   dup f x = f x x
--   
dup :: (a -> a -> b) -> a -> b -- | Compose an arity 1 function with an arity 2 function. B1 - blackbird oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d -- | Compose an arity 1 function with an arity 3 function. B2 - bunting ooo :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e -- | Compose an arity 1 function with an arity 4 function. oooo :: (e -> f) -> (a -> b -> c -> d -> e) -> a -> b -> c -> d -> f -- | Combiners - similar to the cardinal' combinator. -- -- Mnemonically - comb(ine) after applying f to -- x and a single identity: y. -- --
--   combfi comb f x y = comb (f x) y
--   
-- -- Equivalently: -- --
--   combfi comb f = appro comb f id
--   
-- -- But combfi is a useful introduction to the (somewhat manic, but -- sometimes useful) higher arity versions. combfi :: (c -> b -> d) -> (a -> c) -> a -> b -> d -- | Extrapolation of combfi with another identity. -- -- Mnemonically - comb(ine) after applying f to x and -- two identities: y and z. -- --
--   combfii comb f x y z = comb (f x) y z
--   
combfii :: (d -> b -> c -> e) -> (a -> d) -> a -> b -> c -> e -- | Extrapolation of combfii with a further identity. -- -- Mnemonically - comb(ine) after applying f to s and -- three identities: t and u and v. -- --
--   combfii comb f s t u v = comb (f s) t u v
--   
combfiii :: (e -> b -> c -> d -> f) -> (a -> e) -> a -> b -> c -> d -> f