Last active
March 21, 2018 18:10
-
-
Save chessai/83ea07335addb4ea243fc8a242f95e1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class (Bifunctor f) => Biapplicative f where | |
bipure :: a -> b -> f a b | |
biap :: f (a -> b) (c -> d) -> f a c -> f b d | |
class (Bifunctor l, Bifunctor r) => Bimonad l r where | |
bireturnl :: a -> l a b | |
bireturnr :: b -> r a b | |
bijoinl :: l (l a b) (r a b) -> l a b | |
bijoinr :: r (l a b) (r a b) -> r a b | |
-- m >>= f = join (fmap f m) | |
bibindl :: l a b -> (a -> l c d) -> (b -> r c d) -> l c d | |
bibindl lab l r = bijoinl (bimap l r lab) | |
bibindr :: r a b -> (a -> l c d) -> (b -> r c d) -> r c d | |
bibindr rab l r = bijoinr (bimap l r rab) | |
-- the above definition of Bimonad necessitates that the Bimonad is an endofunctor (B : Hask -> Hask) | |
-- relative monads do not have this requirement. | |
class RelativeBimonad j m where | |
bireturn :: j a b -> m a b | |
bibind :: m a b -> (j a b -> m c d) -> m c d | |
--laws: | |
--bireturn jab `bibind` k = k jab | |
--m `bibind` bireturn = m | |
--m `bibind` (\jab -> k jab `bibind` h) = (m `bibind` k) `bibind` h | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment