module Control.Functor.Composition.Extendable (Extendable (..)) where
import "morphisms" Control.Morphism (flip, identity)
import Control.Functor.Composition ((:.:))
import Control.Functor.Covariant (Covariant)
infixl 1 =>>
infixr 1 <<=
class Covariant t => Extendable t where
{-# MINIMAL (=>>) #-}
(=>>) :: t a -> (t a -> b) -> t b
(<<=) :: (t a -> b) -> t a -> t b
(<<=) = flip (=>>)
extend :: (t a -> b) -> t a -> t b
extend f t = t =>> f
duplicate :: t a -> (t :.: t) a
duplicate t = t =>> identity