
16 Oct
2008
16 Oct
'08
7:37 p.m.
Jeff Wheeler
I suspect I should be using some sort of monad to represent the commands, but I don't fully understand monads, and am not sure how it would apply in this context.
Should I be using a monad here, and if so, how?
At risk of stating the obvious, you will need to us the IO monad... When you say "use a monad to represent" the commands, that is perhaps not necessary. You can represent the commands as data, for example: data MyLanguage = Go | Stop | Left | Right runMyLanguage :: MyLanguage -> IO () The `runMyLanguage` function serves to transform commands as pure data into real IO actions. -- _jsn