[Haskell-cafe] Monadic computation must now do IO, fails when type changed to IO.

Matthew Farkas-Dyck strake888 at gmail.com
Fri Jan 6 04:26:16 CET 2012

Dear fellow Haskellers,

I have written an SMTP server (Main.hs at http://hpaste.org/56134,
full git repo at http://strake.zanity.net:1104/ymail.git), which
works, mostly – it responds to every message with that it was sent
properly, whether it was or not. (Try it: send an e-mail by SMTP to
this_is_not_a_user at strake.zanity.net or somesuch.) The reason is, that
it simply tells the message (envelope, data) in a Writer monad, which
is later piped to the local delivery agent.

As I said, this works, but of course is suboptimal. I tried to change
the type of main_ to
(MonadState MTPState m, MonadIO m) => [Char] -> m ([Char], [Char]),
just calling LDA in main_ (when mode is MTPTextMode) rather than
after, but then the program output nil.

I'm not sure what the problem is – I thought IO might not be lazy
enough so I tried a lazy wrapped-IO monad, in vain.

How, then, can this program call the LDA, wait to know whether it
worked or failed, and then respond?

Thanks for any help.

M Farkas-Dyck

More information about the Haskell-Cafe mailing list