forked from GitHub/gf-core
Transfer: added support for disjunctive patterns.
This commit is contained in:
23
transfer/README
Normal file
23
transfer/README
Normal file
@@ -0,0 +1,23 @@
|
||||
Some features of the Transfer language:
|
||||
|
||||
* Purely functional
|
||||
* Dependent types
|
||||
* Eager evaluation
|
||||
* Generalized algebraic datatypes
|
||||
* Metavariables
|
||||
* Records with subtyping
|
||||
* Overloading by explicit dictionary passing
|
||||
* Pattern matching by case expressions
|
||||
|
||||
Additional features in the front-end language:
|
||||
|
||||
* Disjunctive patterns
|
||||
* do-notation
|
||||
* Hidden arguments (not implemented yet)
|
||||
* Automatic derivation of some operations on user-defined GADTs:
|
||||
- Compositional maps and folds
|
||||
- Equality
|
||||
- Ordering
|
||||
- Showing
|
||||
* Pattern equations
|
||||
* Operator syntax for common functions, most are overloaded
|
||||
24
transfer/examples/disjpatt.tr
Normal file
24
transfer/examples/disjpatt.tr
Normal file
@@ -0,0 +1,24 @@
|
||||
data Cat : Type where
|
||||
VarOrWild : Cat
|
||||
Exp : Cat
|
||||
Ident : Cat
|
||||
|
||||
data Tree : Cat -> Type where
|
||||
EAbs : Tree VarOrWild -> Tree Exp -> Tree Exp
|
||||
EPi : Tree VarOrWild -> Tree Exp -> Tree Exp -> Tree Exp
|
||||
EVar : Tree Ident -> Tree Exp
|
||||
EType : Tree Exp
|
||||
EStr : String -> Tree Exp
|
||||
EInt : Integer -> Tree Exp
|
||||
VVar : Tree Ident -> Tree VarOrWild
|
||||
VWild : Tree VarOrWild
|
||||
Ident : String -> Tree Ident
|
||||
|
||||
|
||||
f e = case e of
|
||||
EAbs (VWild || VVar _) e || EPi (VWild || VVar _) _ e -> doSomething e
|
||||
Ident i -> Ident i
|
||||
_ -> catchAll
|
||||
|
||||
|
||||
g (Ident x || EAbs (VWild || VVar _) t e) = x e
|
||||
Reference in New Issue
Block a user