-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Combinators for unorthodox function composition
--   
--   Combinators for unorthodox function composition
@package composition
@version 1.0.2.1


-- | This module is for convenience and demonstrative purposes more than it
--   is for providing actual value. I do not recommend that you rely on
--   this module for performance-sensitive code. Because this module is not
--   based on Prelude's (.), some chances at optimization might be missed
--   by your compiler.
module Data.Composition

-- | The mathematical symbol for function composition.
(∘) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 ∘

-- | Compose two functions. <tt>f .: g</tt> is similar to <tt>f . g</tt>
--   except that <tt>g</tt> will be fed <i>two</i> arguments instead of one
--   before handing its result to <tt>f</tt>.
--   
--   This function is defined as
--   
--   <pre>
--   (f .: g) x y = f (g x y)
--   </pre>
--   
--   Example usage:
--   
--   <pre>
--   concatMap :: (a -&gt; b) -&gt; [a] -&gt; [b]
--   concatMap = concat .: map
--   </pre>
--   
--   Notice how <i>two</i> arguments (the function <i>and</i> the list)
--   will be given to <tt>map</tt> before the result is passed to
--   <tt>concat</tt>. This is equivalent to:
--   
--   <pre>
--   concatMap f xs = concat (map f xs)
--   </pre>
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
infixr 8 .:

-- | One compact pattern for composition operators is to "count the dots
--   after the first one", which begins with the common <a>.:</a>, and
--   proceeds by first appending another <tt>.</tt> and then replacing it
--   with <tt>:</tt>
(.:.) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
infixr 8 .:.
(.::) :: (d -> e) -> (a1 -> a -> b -> c -> d) -> a1 -> a -> b -> c -> e
infixr 8 .::
(.::.) :: (d -> e) -> (a2 -> a1 -> a -> b -> c -> d) -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .::.
(.:::) :: (d -> e) -> (a3 -> a2 -> a1 -> a -> b -> c -> d) -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .:::
(.:::.) :: (d -> e) -> (a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .:::.
(.::::) :: (d -> e) -> (a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .::::
(.::::.) :: (d -> e) -> (a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .::::.

-- | Equivalent to <a>.:</a>
--   
--   The pattern of appending asterisks is straightforward to extend to
--   similar functions: (compose2 = .*, compose3 = .**, etc). However,
--   <tt>.:</tt> has been commonly adopted amongst Haskellers, and the need
--   for compose3 and beyond is rare in practice.
(.*) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
infixr 8 .*
(.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
infixr 8 .**
(.***) :: (d -> e) -> (a1 -> a -> b -> c -> d) -> a1 -> a -> b -> c -> e
infixr 8 .***
(.****) :: (d -> e) -> (a2 -> a1 -> a -> b -> c -> d) -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .****
(.*****) :: (d -> e) -> (a3 -> a2 -> a1 -> a -> b -> c -> d) -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .*****
(.******) :: (d -> e) -> (a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .******
(.*******) :: (d -> e) -> (a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .*******
(.********) :: (d -> e) -> (a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
infixr 8 .********

-- | <tt>composeN f g</tt> means give <tt>g</tt> <tt>N</tt> inputs and then
--   pass its result to <tt>f</tt>.
compose1 :: (b -> c) -> (a -> b) -> a -> c
compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
compose3 :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
compose4 :: (d -> e) -> (a1 -> a -> b -> c -> d) -> a1 -> a -> b -> c -> e
compose5 :: (d -> e) -> (a2 -> a1 -> a -> b -> c -> d) -> a2 -> a1 -> a -> b -> c -> e
compose6 :: (d -> e) -> (a3 -> a2 -> a1 -> a -> b -> c -> d) -> a3 -> a2 -> a1 -> a -> b -> c -> e
compose7 :: (d -> e) -> (a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
compose8 :: (d -> e) -> (a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
compose9 :: (d -> e) -> (a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> d) -> a6 -> a5 -> a4 -> a3 -> a2 -> a1 -> a -> b -> c -> e
