Guest User

Untitled

a guest
Feb 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. standardLib = Standard $ Map.fromList
  2. [("put-line", StandardEntry { eSerialize = Cons (Label "native") (Cons (Label "put-line") Nil)
  3. , eApply = aPutLine
  4. , eExecute = ePutLine })
  5. ,("get-line", StandardEntry { eSerialize = Cons (Label "native") (Cons (Label "get-line") Nil)
  6. , eApply = aGetLine
  7. , eExecute = eGetLine })]
  8.  
  9. aPutLine (m, x) = Cons (Label "put-line") x
  10.  
  11. ePutLine (m, Cons (Label x) Nil) = do putStrLn x
  12. return (m, Nil)
  13. ePutLine (m, Cons (Label x) d) = do putStrLn x
  14. ePutLine (m, d)
  15. ePutLine (m, Nil) = return (m, Nil)
  16. ePutLine (m, b) = E.throw $ RuntimeException "type mismatch"
  17.  
  18. aGetLine (m, x) = Cons (Label "get-line") x
  19.  
  20. eGetLine (m, _) = do l <- getLine
  21. return (m, Label l)
Add Comment
Please, Sign In to add comment