Advertisement
Guest User

typefamily

a guest
Jun 17th, 2022
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. {-# LANGUAGE DataKinds, GADTs, KindSignatures, PatternSynonyms, TypeFamilies #-}
  2.  
  3. data K = A | B | C {-| Illegal-}
  4.  
  5. type family App (k :: K) (k' :: K) :: K where
  6. App 'B 'B = 'A
  7. App 'C 'C = 'B
  8. {-App _ _ = 'Illegal-}
  9.  
  10. data T (k :: K) where
  11. CT :: T 'A
  12. ET :: T k
  13. AT :: T k -> T k' -> T (App k k')
  14.  
  15. type A = T 'A
  16. type B = T 'B
  17. type C = T 'C
  18.  
  19. pattern TA :: B -> B -> A
  20. pattern TA xb yb = AT xb yb
  21.  
  22. pattern TB :: C -> C -> B
  23. pattern TB xc yc = AT xc yc
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement