composition-0.2.1: src/Data/Composition.hs
module Data.Composition (
(.:),
(.*),
(.**),
(.***),
(.****),
(.*****),
(.******),
(.*******),
(.********),
compose2,
compose3,
compose4,
compose5,
compose6,
compose7,
compose8,
compose9
) where
-- | This function is defined as
--
-- > (.:) f g x y = f (g x y)
--
-- Example usage: @bind = join .: flip fmap@
-- Notice how two arguments will be given to @flip fmap@ before the result
-- is passed to @join@.
--
-- This is equivalent to @bind v f = join (fmap v f)@
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(.:) f g x y = f (g x y)
-- | Equivalent to '(.:)'
--
-- The pattern of appending asterisks is more extensible,
-- but uncommon in practice.
(.*) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(.*) = (.) . (.)
(.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
(.**) = (.) . (.*)
(.***) = (.) . (.**)
(.****) = (.) . (.***)
(.*****) = (.) . (.****)
(.******) = (.) . (.*****)
(.*******) = (.) . (.******)
(.********) = (.) . (.*******)
compose2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
compose2 = (.*)
compose3 :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
compose3 = (.**)
compose4 = (.***)
compose5 = (.****)
compose6 = (.*****)
compose7 = (.******)
compose8 = (.*******)
compose9 = (.********)