Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-# Language
  2. Rank2Types,
  3. GADTs,
  4. DataKinds,
  5. PolyKinds,
  6. TypeFamilies,
  7. DatatypeContexts,
  8. MultiParamTypeClasses,
  9. UndecidableInstances,
  10. UndecidableSuperClasses
  11. #-}
  12.  
  13.  
  14. import GHC.Exts
  15.  
  16. data Stream s a = Stream (a,s)
  17.  
  18. data Linear s a = Linear (a,s) | End a
  19.  
  20. data Stack  s a = Stack  (a,s) | Empty
  21.  
  22. data Basecase s a where
  23.  Stream' :: Stream s a -> Basecase s a
  24. Linear' :: Linear s a -> Basecase s a
  25.  Stack'  :: Stack  s a -> Basecase s a
  26.  
  27. data Proxy k = Proxy
  28.  
  29. class Flat f where -- not considering Nested Base functors yet, so no Trees etc
  30. type FlatBase f :: Proxy Basecase
  31.  
  32. type State   (x :: Proxy b) s a = s -> b s a
  33.  
  34. type CoState (x :: Proxy b) s a = b s a -> s
  35.  
  36. class Flat f => Get f where
  37. get :: CoState (FlatBase f) (f a) a
  38.  
  39. class Flat f => Set f where
  40. set :: State (FlatBase f) (f a) a
  41.  
  42. data (Get f,Set f) => Zipper f a = Zipper [a] (f a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement