Guest User

Untitled

a guest
Apr 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. class BuildList r where
  2. type Build r
  3. build' :: [Build r] -> Build r -> r
  4.  
  5. instance BuildList [a] where
  6. type Build [a] = a
  7. build' l x = reverse $ x:l
  8.  
  9. instance BuildList r => BuildList (a-> r) where
  10. type Build (a -> r) = Build r
  11. build' l x = \ y -> build'(x:l) y
  12.  
  13. -- --build :: forall r a. (BuildList a r) => a -> r
  14. -- build :: (BuildList a r) => a -> r
  15. -- build x = build' [] x
  16.  
  17. class Mutation m where
  18. type Ref m :: * -> *
  19. newRef :: a -> m (Ref m a)
  20. readRef :: (Ref m a) -> m a
  21. writeRef :: (Ref m a) -> a -> m ()
  22.  
  23. instance Mutation IO where
  24. type Ref IO = IORef
  25. newRef = newIORef
  26. readRef = readIORef
  27. writeRef = writeIORef
Add Comment
Please, Sign In to add comment