module Control.Functor.Covariant.Composition.Bindable (Bindable (..)) where
import "morphisms" Control.Morphism (($), flip, identity)
import Control.Functor.Covariant (Covariant ((<$>)))
import Control.Variance ((:.:))
infixl 1 >>=
infixr 1 =<<, <=<, >=>
class Covariant t => Bindable t where
{-# MINIMAL (>>=) #-}
(>>=) :: t a -> (a -> t b) -> t b
(=<<) :: (a -> t b) -> t a -> t b
(=<<) = flip (>>=)
bind :: (a -> t b) -> t a -> t b
bind f t = t >>= f
join :: (t :.: t) a -> t a
join t = t >>= identity
(>=>) :: (a -> t b) -> (b -> t c) -> (a -> t c)
f >=> g = \x -> f x >>= g
(<=<) :: (b -> t c) -> (a -> t b) -> (a -> t c)
(<=<) = flip (>=>)