composition-prelude-0.1.1.4: Higher-order function combinators

Control.Composition

Synopsis

• (.*) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
• (.**) :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e
• (.***) :: (e -> f) -> (a -> b -> c -> d -> e) -> a -> b -> c -> d -> f
• (-.) :: (a -> b) -> (b -> c) -> a -> c
• (-.*) :: (b -> c) -> (a -> c -> d) -> a -> b -> d
• (-.**) :: (c -> d) -> (a -> b -> d -> e) -> a -> b -> c -> e
• (-.***) :: (d -> e) -> (a -> b -> c -> e -> f) -> a -> b -> c -> d -> f

# Tuple helpers

both :: (a -> b) -> (a, a) -> (b, b) Source #

# Reexports from Control.Arrow

(&&&) :: Arrow a => forall b c c'. a b c -> a b c' -> a b (c, c') infixr 3 #

Fanout: send the input to both argument arrows and combine their output.

The default definition may be overridden with a more efficient version if desired.

(***) :: Arrow a => forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #

Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.

The default definition may be overridden with a more efficient version if desired.

join :: Monad m => m (m a) -> m a #

The join function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.

(=<<) :: Monad m => (a -> m b) -> m a -> m b infixr 1 #

Same as >>=, but with the arguments interchanged.

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #

(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 #

Right-to-left Kleisli composition of monads. (>=>), with the arguments flipped.

Note how this operator resembles function composition (.):

(.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

# Reexports from base

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

Since: 4.8.0.0

fix :: (a -> a) -> a #

fix f is the least fixed point of the function f, i.e. the least defined x such that f x = x.

on :: (b -> b -> c) -> (a -> b) -> a -> a -> c infixl 0 #

(*) on f = \x y -> f x * f y.

Typical usage: sortBy (compare on fst).

Algebraic properties:

• (*) on id = (*) (if (*) ∉ {⊥, const ⊥})
• ((*) on f) on g = (*) on (f . g)
• flip on f . flip on g = flip on (g . f)

ap :: Monad m => m (a -> b) -> m a -> m b #

In many situations, the liftM operations can be replaced by uses of ap, which promotes function application.

      return f ap x1 ap ... ap xn

is equivalent to

      liftMn f x1 x2 ... xn