Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. {-# LANGUAGE DataKinds #-}
  2. {-# LANGUAGE GADTs #-}
  3. {-# LANGUAGE TypeFamilies #-}
  4. {-# LANGUAGE TypeOperators #-}
  5.  
  6.  
  7.  
  8. module Serialization where
  9.  
  10. data Nat = Zero | Suc Nat
  11.  
  12.  
  13.  
  14. data family Frame (s :: [*]) (s' :: [*])
  15.  
  16. infixr :.
  17.  
  18. data Stack (s :: [*]) where
  19. Done :: Stack '[]
  20. (:.) :: Frame s s' -> Stack s' -> Stack s
  21.  
  22. data instance Frame (Bool ': s) s' where
  23. TrueS :: Frame (Bool ': s) s
  24. FalseS :: Frame (Bool ': s) s
  25.  
  26. data instance Frame (Nat ': s) s' where
  27. ZeroS :: Frame (Nat ': s) s
  28. SucS :: Frame (Nat ': s) (Nat ': s)
  29.  
  30. data instance Frame ((a,b) ': s) s' where
  31. PairS :: Frame ((a,b) ': s) (a ': b ': s)
  32.  
  33. data instance Frame ([a] ': s) s' where
  34. NilS :: Frame ([a] ': s) s
  35. ConsS :: Frame ([a] ': s) (a ': [a] ': s)
  36.  
  37.  
  38. s :: Stack '[[(Nat,Bool)]]
  39. s =
  40. ConsS :.
  41. PairS :.
  42. SucS :.
  43. ZeroS :.
  44. TrueS :.
  45. ConsS :.
  46. PairS :.
  47. ZeroS :.
  48. FalseS :.
  49. NilS :.
  50. Done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement