Advertisement
Guest User

Untitled

a guest
Jul 20th, 2020
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-#GADTs,KindSignatures,ScopedTypeVariables,TypeOperators,PolyKinds,RankNTypes#-}
  2.  
  3.  
  4. data Tuple :: [Type] -> Type where
  5.   TNil :: Tuple '[]
  6.  TCons :: a -> Tuple l -> Tuple (a:l)
  7.  
  8. data EncodingType' = FinType'|ConstrType'
  9.  
  10. data EncodingType :: EncodingType' -> Type where
  11.  ConstrType :: [Type] ->EncodingType ConstrType'
  12.   ConstrSumType :: EncodingType ConstrType' -> EncodingType ConstrType' -> EncodingType ConstrType'
  13.  FinType :: EncodingType ConstrType' -> EncodingType FinType'
  14.  
  15. data Encoding :: forall (p :: EncodingType').(EncodingType p) -> (Type -> Type -> Type) -> Type -> Type where
  16.   Constr :: a (Tuple l) t -> Encoding (ConstrType l) a t
  17.   ConstrSum :: Encoding (ConstrType c1) a t-> Encoding (ConstrType c2) a t-> Encoding (ConstrSumType (ConstrType c1) (ConstrType c2)) a t
  18.   Fin :: forall (a :: Type -> Type -> Type) (t :: Type) (l :: EncodingType ConstrType').a (Encoding l a t) t -> Encoding (FinType l) a t
  19.  
  20.  
  21.  
  22. {-examples-}
  23. type ArrId a b = forall id.Encoding (FinType (ConstrType '[b])) a id
  24. type ArrPair a b c = forall pair.Encoding (FinType (ConstrType '[b,c])) a pair
  25. type ArrEither a e b = forall either.Encoding (FinType (ConstrSumType (ConstrType '[e]) (ConstrType '[b]))) a either
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement