[Haskell-beginners] How do I perform things inside a Monad?

Martin Drautzburg Martin.Drautzburg at web.de
Thu Feb 7 23:07:57 CET 2013

Hello all,

In the ALSA Midi package, there is an example, where he first sets up client, 
port, queue and stuff. All of these are IO actions, and there are a number of 
nested "do"s. Then in the innermost "do" he has all the pieces together and 
starts playing. In this case the actual "song" is coded in the innermost do.

My question is: how can I inject a song from outside. Of course I could make 
it another parameter, which would have to travel through all the "do"s, but I 
already have more than enough parameters.

Then I tried fmap. But the actual playing is an IO operation itself, so I 
cannot write a pure function and fmap it over the Monad.

Any ideas?


More information about the Beginners mailing list