Created
September 12, 2017 15:40
-
-
Save haileys/b0b852a8a7b3a3968e3d073f64fe8c72 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
import Control.Monad | |
import Data.Monoid | |
data MState s a = MState s a | |
instance Monoid s => Functor (MState s) where | |
fmap f (MState st x) = MState st (f x) | |
instance Monoid s => Applicative (MState s) where | |
pure = return | |
(<*>) = ap | |
instance Monoid s => Monad (MState s) where | |
return x = MState mempty x | |
(>>=) (MState st x) f = MState (mappend st st') x' | |
where (MState st' x') = f x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment