Exercise

27 February

  1. Assume the following datatype declaration:
    data STree a = Leaf a | Branch [STree a]
    
    Define (and, at home, verify) a Functor instance for STree.
  2. Produce the Haskell class declaration for the type class Monad and state its invariants.
  3. How is the do notation translated into core Haskell using Monad class members?
  4. Define (and, at home, verify) a Monad instance for Either e.

    Why the letter ``e''?

  5. Define (and, at home, verify) a Monad instance for STree.
  6. Assume the following datatype declaration:
    newtype State s a = State {runState :: (s -> (a, s))}
    
    Define (and, at home, verify) a Functor instance for State s.
  7. Define (and, at home, verify) a Monad instance for State s.
  8. Assume the following datatype declaration:
    newtype StateT s (m::* -> *) a = StateT {runStateT :: (s -> m (a, s))}
    
    Define (and, at home, verify) a Monad instance for StateT s m.

After Class


So I don't forget...


Wolfram Kahl: FP2006