module Control.Morphism (after, to, by, constant, identity, flip, fix, between, (.), ($), (&), (!), (?), (#), (.^.)) where
infixr 9 .
infixr 0 $
infixl 1 &
infixr 2 !
infixr 2 ?
{-# INLINE after #-}
after :: (b -> c) -> (a -> b) -> a -> c
after f g = \x -> f (g x)
{-# INLINE to #-}
to :: (a -> b) -> a -> b
to f x = f x
{-# INLINE by #-}
by :: a -> (a -> b) -> b
by x f = f x
{-# INLINE flip #-}
flip :: (a -> b -> c) -> b -> a -> c
flip f x y = f y x
{-# INLINE constant #-}
constant :: a -> b -> a
constant x y = x
fix :: (a -> a) -> a
fix f = let x = f x in x
{-# INLINE identity #-}
identity :: a -> a
identity x = x
{-# INLINE between #-}
between :: (c -> d) -> (a -> b) -> (b -> c) -> a -> d
between f g = (f .) . (. g)
{-# INLINE (?) #-}
(?) = constant
{-# INLINE (.) #-}
(.) = after
{-# INLINE ($) #-}
($) = to
{-# INLINE (&) #-}
(&) = by
{-# INLINE (!) #-}
(!) = flip
(#) = fix
(.^.) = between