diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-03-20 14:04:11 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-03-20 14:04:11 +0000 |
| commit | d760ce973896bbfd5e9f62516bb953cfeeabaf1a (patch) | |
| tree | f3aa5848911655a34fded8115c87b75d08855880 /transfer/examples | |
| parent | 2371a1fccaf0e02aa804830e93e6c8e25539a7e7 (diff) | |
Added some tricky transfer type checking examples.
Diffstat (limited to 'transfer/examples')
| -rw-r--r-- | transfer/examples/tricky-type-checking.tra | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/transfer/examples/tricky-type-checking.tra b/transfer/examples/tricky-type-checking.tra new file mode 100644 index 000000000..4cc8037ba --- /dev/null +++ b/transfer/examples/tricky-type-checking.tra @@ -0,0 +1,31 @@ + +-- +-- Pattern matching and inductive families. +-- + +data Tree : Type -> Type where + EAdd : Tree Integer -> Tree Integer -> Tree Integer + EInt : Integer -> Tree Integer + EFoo : (A:Type) -> A -> Tree A + +strip : (B : Type) -> Tree B -> B +strip _ t = case t of + EAdd x y -> x+y + EInt i -> i + EFoo _ x -> x + +-- +-- Subtyping +-- + +getX : { x : Integer } -> Integer +getX r = r.x + +getY : { y : Integer } -> Integer +getY r = r.y + +proj2 : (A:Type) -> (B:Type) -> (C:Type) -> (A -> B) -> (A -> C) -> A -> (B,C) +proj2 _ _ _ f g x = (f x, g x) + +getXY : { x : Integer, y : Integer } -> (Integer,Integer) +getXY r = proj2 ? ? ? getX getY r |
