
On Jan 13, 2008 12:47 AM, Brian Hurt
So, I've been playing around with what I call the trivial monad:
module TrivialMonad where
data TrivialMonad a = M a
Better to use newtype here; then it really is operationally equivalent to using just "a", except that it's possible to implement a monad instance for it (see below).
The first question I have is it is possible to implement this guy without wrapping the value in a constructor? What I'd like to do is replace the: data TrivialMonad a = M a with something like: type TrivialMonad a = a and then be able to junk the recover function.
Nope. That would mean that every type is a monad, which would cause endless troubles for type inference. For example, what monad is (putStrLn "x") a member of: IO () or TrivialMonad (IO ()) (or even TrivialMonad (TrivialMonad (IO())))?
The second question I have is: is there any hope of getting something like this into the standard library?
Control.Monad.Identity, perhaps? http://www.haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-Iden... Luke