[Haskell-cafe] Terminal-like Application Design

Jason Dusek jason.dusek at gmail.com
Thu Oct 16 19:37:14 EDT 2008

Jeff Wheeler <jeff at nokrev.com> wrote:
> 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

  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.


More information about the Haskell-Cafe mailing list