[Haskell-beginners] IO / State / Do Syntax

Alexander Bernauer alex-haskell at copton.net
Mon Aug 27 13:49:35 CEST 2012


you don't need the State monad for your problem. Standard functional
composition is enough:

initResources =
      images = ["someimage.png", "someimage2.png"]
      keywords = ["pic1keyword", "pic2keyword"]
   in do
       pics <- mapM loadImage images
       let rt = foldr go emptyResourceTracker $ zip pics keywords
       -- use rt
      go (pic, kw) rt = storeImage rt kw pic

Anyways, if you are interested in Monad transformers in general, go
check out http://book.realworldhaskell.org/read/monad-transformers.html


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120827/c5f15557/attachment.pgp>

More information about the Beginners mailing list