Hi haskell-beginners,
I'm starting to come to the idea of exposing a Monad as a means of controlling an API.  So, I've started creating my own Monad data types based on classical monads.  However, I'm running into a problem regarding creating monad definitions when using nested Monads.
For example:
newtype Example m o = Example {
  runExample :: State Int (m o)
}
Is there a clean way to make Example a monad?
instance Monad m => Monad (Example m) where
  -- return is easy
  return = Example . return . return
  -- bind is hard.
  -- f :: o -> Example m p
  -- a :: Example m o 
  a >>= f = ...
My intuition tells me that this should be simple, I should just use the State's bind operation, but I can't seem to make it work.
Any advise would be great.
Thanks, Dave
-- 
David Hinkes