Skip to content

Instantly share code, notes, and snippets.

@naomik

naomik/MyState.hs

Forked from merijn/MyState.hs
Last active Aug 29, 2015
Embed
What would you like to do?
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.