Advertisement
Guest User

Untitled

a guest
Oct 25th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. talk :: MVar State -> String -> Handle -> IO ()
  2. talk mvar address h = do
  3. line <- hGetLine h
  4. state <- takeMVar mvar
  5. putStrLn line
  6. let result = parseLine state address line
  7. let newState = fst result
  8. let answer = snd result
  9. putMVar mvar newState
  10. case answer of
  11. Just value -> hPutStrLn h value
  12. Nothing -> return ()
  13. talk mvar address h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement