Skip to content

Instantly share code, notes, and snippets.

@UnkindPartition
Last active August 29, 2015 14:14
Show Gist options
  • Save UnkindPartition/aab02fb2699f1ae40c40 to your computer and use it in GitHub Desktop.
Save UnkindPartition/aab02fb2699f1ae40c40 to your computer and use it in GitHub Desktop.
import Data.List
mutual
data Ty = TyInt | TyFun Ty Ty | TyData DataDesc
data DataDesc =
MkDataDesc
String -- data type name
(List ConDesc) -- list of constructors
data ConDesc : Type where
MkConDesc
: (d: DataDesc) -- parent data type
-> (conElem ?con d) -- ?con should refer to this very value we're defining
-> String -- constructor name
-> (List Ty) -- list of fields
-> ConDesc
||| Proof that a constructor belongs to a datatype
conElem : ConDesc -> DataDesc -> Type
conElem con (MkDataDesc _ constrs) = Elem con constrs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment