Created
February 22, 2012 12:29
-
-
Save mklinik/1884761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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