Skip to content

Instantly share code, notes, and snippets.

@miaout17
Created July 24, 2009 18:42
Show Gist options
  • Save miaout17/154472 to your computer and use it in GitHub Desktop.
Save miaout17/154472 to your computer and use it in GitHub Desktop.
type MockIO = State MockIOData
instance CharIO MockIO where
getCh = do
d <- get
case d of
MockIOData (i:is) o -> do
put $ MockIOData is o
return $ Just i
MockIOData [] _ ->
return Nothing
putCh c = modify $ \s -> s{moOutput = moOutput s ++ [c]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment