[Haskell-beginners] strict evaluation and MIDI playback

Dennis Raddle dennis.raddle at gmail.com
Fri Nov 6 21:32:36 UTC 2015

I wrote a program in Haskell that does real-time MIDI playback. This
involves computing what are called MIDI "events" (things like notes and
volume controls) and then using the PortMidi library to play back the
events. PortMidi also provides a time reading function that is accurate to
1 millisecond which is useful for timing the playback accurately.

I used 'evaluate' in the IO Monad to make sure that all events were fully
computed before playback started. However I was still getting delays
(timing errors). I added some code to the program that wrote the data to
disk before playing it back, and the timing errors went away. Apparently
'evaluate' was not forcing a complete evaluation, while writing a disk file
was. Or at least I think that's what happened.

But writing to disk is a hack. What can I do to get 'evaluate' to work?

A simplified version of the code is here: (the actual program is pretty
long and complex so I posted something which is stripped down but I hope
retains the essential features)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151106/7480f597/attachment.html>

More information about the Beginners mailing list