Ok, that works. On to code reading and, hopefully, enlightenment.
Thanks, all.
Michael
--- On Sun, 12/26/10, Daniel Fischer <daniel.is.fischer@googlemail.com> wrote:
From: Daniel Fischer <daniel.is.fischer@googlemail.com> Subject: Re: [Haskell-cafe] Intro to monad transformers To: haskell-cafe@haskell.org Cc: "michael rice" <nowgate@yahoo.com>, "David Menendez" <dave@zednenem.com> Date: Sunday, December 26, 2010, 4:07 PM
On Sunday 26 December 2010 21:21:00, michael rice wrote: > Ok, changed the last line and deleted the bad line. Maybe someone could > recommend a better example? > > Michael > > ============= > >
Prelude> :l test5 > [1 of 1] Compiling Main ( test5.hs, interpreted ) > > test5.hs:16:4: > Occurs check: cannot construct the infinite type: a = Maybe a > When generalising the type(s) for `mplus' > In the instance declaration for `MonadPlus (MaybeT m)' > Failed, modules loaded: none. > >
> mplus x y = MaybeT $ do maybe_value <- runMaybeT x > > case maybe_value > of >
Nothing -> runMaybeT y > Just value -> runMaybeT x > > The last line is wrong. It should be, "Just value -> return value".
Actually, it should be
case maybe_value of Nothing -> runMaybeT y _ -> return maybe_value
|