[Haskell-beginners] monads do not fit together?

Kees Bleijenberg k.bleijenberg at lijbrandt.nl
Tue Oct 15 09:00:04 UTC 2013


Brandon,

 

Thanks you for your advice.

I want to add CGI support to  a program that writes to a file, but has no network access. The old code uses a WriterT with IO in it. Adding another monad to the stack with IO to the network, is a bit too difficult for a beginner like me.

The old code returns IO [String] ([String] = list of status messages). It is a bit annoying that I have to adapt the old code. I just want to grab the status messages and convert them to html and write them to the network. 

I wonder, do you always have to create a monadtransformer if your program uses 2 kinds of IO?

 

Kees 

 

 

Van: Beginners [mailto:beginners-bounces at haskell.org] Namens Brandon Allbery
Verzonden: maandag 14 oktober 2013 17:03
Aan: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell
Onderwerp: Re: [Haskell-beginners] monads do not fit together?

 

On Mon, Oct 14, 2013 at 10:58 AM, Kees Bleijenberg <k.bleijenberg at lijbrandt.nl> wrote:

I get the same message (Couldn't match expected type `CGIT IO a0'   with actual type `IO [String]'). I think I do understand where this message is coming from. But what can I do to fix it?

 

For now, you just correct the type of runRefreshFirewall; it should be

 

    runRefreshFirewall :: String -> CGIT IO [String]

 

If you are intending to run actual IO actions in the real thing, you'll need to use liftIO to "reach" the IO embedded in the CGIT IO a.

 

-- 

brandon s allbery kf8nh                               sine nomine associates

allbery.b at gmail.com                                  ballbery at sinenomine.net

unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131015/ec944256/attachment.html>


More information about the Beginners mailing list