Last active
January 15, 2021 19:20
-
-
Save merijn/098106abd45c940dab09 to your computer and use it in GitHub Desktop.
MyState homework
This file contains 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
data MyState s a = MyState (s -> (a, s)) | |
get :: MyState s s | |
get = undefined | |
put :: s -> MyState s () | |
put = undefined | |
modify :: (s -> s) -> MyState s () | |
modify = undefined | |
instance Functor (MyState s) where | |
-- fmap :: (a -> b) -> (MyState s) a -> (MyState s) b | |
fmap = undefined | |
instance Applicative (MyState s) where | |
-- pure :: a -> (MyState s) a | |
pure = undefined | |
-- (<*>) :: (MyState s) (a -> b) -> (MyState s) a -> (MyState s) b | |
(<*>) = undefined | |
instance Monad (MyState s) where | |
-- return :: a -> (MyState s) a | |
return = pure | |
-- (>>=) :: (MyState s) a -> (a -> (MyState s) b) -> (MyState s) b | |
(>>=) = undefined |
This file contains 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
data MyStateT s m a = MyStateT (s -> m (a, s)) | |
get :: Monad m => MyStateT s m s | |
get = undefined | |
put :: Monad m => s -> MyStateT s m () | |
put = undefined | |
modify :: Monad m => (s -> s) -> MyStateT s m () | |
modify = undefined | |
instance Monad m => Functor (MyStateT s m) where | |
-- fmap :: (a -> b) -> (MyStateT s m) a -> (MyStateT s m) b | |
fmap = undefined | |
instance Monad m => Applicative (MyStateT s m) where | |
-- pure :: a -> (MyStateT s m) a | |
pure = undefined | |
-- (<*>) :: (MyStateT s m) (a -> b) -> (MyStateT s m) a -> (MyStateT s m) b | |
(<*>) = undefined | |
instance Monad m => Monad (MyStateT s m) where | |
-- return :: a -> (MyStateT s m) a | |
return = pure | |
-- (>>=) :: (MyStateT s m) a -> (a -> (MyStateT s m) b) -> (MyStateT s m) b | |
(>>=) = undefined | |
instance MonadTrans (MyStateT s) where | |
-- lift :: Monad m => m a -> MyStateT s m a | |
lift = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment