module Pandora.Pattern.Functor.Bindable where
import Pandora.Core.Functor (type (:.), type (:=))
import Pandora.Pattern.Functor.Covariant (Covariant ((<$>)))
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
a -> t b
f =<< t a
x = t a
x t a -> (a -> t b) -> t b
forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b
>>= a -> t b
f
bind :: (a -> t b) -> t a -> t b
bind a -> t b
f t a
t = t a
t t a -> (a -> t b) -> t b
forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b
>>= a -> t b
f
join :: t :. t := a -> t a
join (t :. t) := a
t = (t :. t) := a
t ((t :. t) := a) -> (t a -> t a) -> t a
forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b
>>= \t a
x -> t a
x
(>=>) :: (a -> t b) -> (b -> t c) -> (a -> t c)
a -> t b
f >=> b -> t c
g = \a
x -> a -> t b
f a
x t b -> (b -> t c) -> t c
forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b
>>= b -> t c
g
(<=<) :: (b -> t c) -> (a -> t b) -> (a -> t c)
b -> t c
g <=< a -> t b
f = a -> t b
f (a -> t b) -> (b -> t c) -> a -> t c
forall (t :: * -> *) a b c.
Bindable t =>
(a -> t b) -> (b -> t c) -> a -> t c
>=> b -> t c
g
($>>=) :: Covariant u => u :. t := a -> (a -> t b) -> u :. t := b
(u :. t) := a
x $>>= a -> t b
f = (t a -> (a -> t b) -> t b
forall (t :: * -> *) a b. Bindable t => t a -> (a -> t b) -> t b
>>= a -> t b
f) (t a -> t b) -> ((u :. t) := a) -> (u :. t) := b
forall (t :: * -> *) a b. Covariant t => (a -> b) -> t a -> t b
<$> (u :. t) := a
x