We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22cedc3 commit 394db07Copy full SHA for 394db07
ITMOPrelude/Monads.hs
@@ -0,0 +1,29 @@
1
+{-# LANGUAGE NoImplicitPrelude, FlexibleInstances, UndecidableInstances #-}
2
+module ITMOPrelude.Monads where
3
+
4
+import ITMOPrelude.Category
5
6
+id x = x
7
8
+class MonadFish m where
9
+ returnFish :: a -> m a
10
+ (>=>) :: (a -> m b) -> (b -> m c) -> a -> m c
11
12
+instance Monad m => Functor m where
13
+ fmap f x = x >>= f
14
15
+class Functor m => MonadJoin m where
16
+ returnJoin :: a -> m a
17
+ join :: m (m a) -> m a
18
19
+instance Monad m => MonadFish m where
20
+ returnFish = return
21
+ f >=> g = \a -> f a >>= \b -> g b
22
23
+instance MonadFish m => Monad m where
24
+ return = returnFish
25
+ ma >>= f = id >=> f ma
26
27
+instance MonadJoin m => Monad m where
28
+ return = returnJoin
29
+ f >>= g = join (fmap g f)
0 commit comments