Guest User

Untitled

a guest
Feb 26th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. lolcathost% ghci
  2. GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
  3. > import Data.IORef
  4. import Data.IORef
  5. > x <- newIORef 5
  6. > let f y = (+) <$> readIORef x <*> pure y
  7. > f 10
  8. 15
  9. > writeIORef x 0
  10. > f 10
  11. 10
  12. >
  13. Leaving GHCi.
  14. lolcathost% poly
  15. Poly/ML 5.6 Release
  16. > val x = ref 5;
  17. val x = ref 5: int ref
  18. > fun f y = !x + y;
  19. val f = fn: int -> int
  20. > f 10;
  21. val it = 15: int
  22. > x := 0;
  23. val it = (): unit
  24. > f 10;
  25. val it = 10: int
  26. lolcathost%
Advertisement
Add Comment
Please, Sign In to add comment