Skip to content

Instantly share code, notes, and snippets.

@mklinik
Created February 22, 2012 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mklinik/1884761 to your computer and use it in GitHub Desktop.
Save mklinik/1884761 to your computer and use it in GitHub Desktop.
import Control.Monad.State
data Message = MsgA | MsgB
deriving (Show, Eq)
class Monad m => MonadHmud m where
getMessage :: m Message
instance MonadHmud IO where
getMessage = do
l <- getLine
case l of
[] -> return MsgA
otherwise -> return MsgB
-- instance MonadHmud (State [Message]) where
-- getMessage [] = (MsgA, [])
-- getMessage (m:ms) = (m, ms)
main = do
m <- getMessage
print m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment