Control.Monad.Reader defines instances of Monad and MonadReader for
((->) r). Strangely enough, the documentation claims the Monad instance
comes from Control.Monad, which is untrue.

Here's the relevant chunk of the file. It looks like you came up with
exactly the same code (modulo names).

-- 
----------------------------------------------------------------------------
-- The partially applied function type is a simple reader monad

instance Functor ((->) r) where
   fmap = (.)

instance Monad ((->) r) where
   return  = const
   m >>= k = \r -> k (m r) r

instance MonadFix ((->) r) where
   mfix f = \r -> let a = f a r in a

instance MonadReader r ((->) r) where
   ask       = id
   local f m = m . f

Brandon

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to