summaryrefslogtreecommitdiff
path: root/transfer/examples/exp.tra
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2005-12-06 16:33:40 +0000
committerbringert <bringert@cs.chalmers.se>2005-12-06 16:33:40 +0000
commitc703a92136ce579282c63c6e31fff76cc84b37ce (patch)
treee0dedf8972756fa1322bb4d8a0c621a629bedc1e /transfer/examples/exp.tra
parentee4adf5ba8ff50b4580a18d197f9e05d36195ede (diff)
Transfer: Changed transfer program file extension from .tr to .tra to avoid collision with Troff file extension.
Diffstat (limited to 'transfer/examples/exp.tra')
-rw-r--r--transfer/examples/exp.tra33
1 files changed, 33 insertions, 0 deletions
diff --git a/transfer/examples/exp.tra b/transfer/examples/exp.tra
new file mode 100644
index 000000000..e54b82055
--- /dev/null
+++ b/transfer/examples/exp.tra
@@ -0,0 +1,33 @@
+import prelude
+
+data Cat : Type where
+ Stm : Cat
+ Exp : Cat
+ Var : Cat
+ Typ : Cat
+ ListStm : Cat
+
+data Tree : Cat -> Type where
+ SDecl : Tree Typ -> Tree Var -> Tree Stm
+ SAss : Tree Var -> Tree Exp -> Tree Stm
+ SBlock : Tree ListStm -> Tree Stm
+ EAdd : Tree Exp -> Tree Exp -> Tree Exp
+ EStm : Tree Stm -> Tree Exp
+ EVar : Tree Var -> Tree Exp
+ EInt : Integer -> Tree Exp
+ V : String -> Tree Var
+ TInt : Tree Typ
+ TFloat : Tree Typ
+
+ NilStm : Tree ListStm
+ ConsStm : Tree Stm -> Tree ListStm -> Tree ListStm
+
+derive Compos Tree
+
+rename : (String -> String) -> (C : Type) -> Tree C -> Tree C
+rename f C t = case t of
+ V x -> V (f x)
+ _ -> composOp ? ? compos_Tree C (rename f) t
+
+
+main = rename (const ? ? "apa") Stm (SAss (V "y") (EAdd (EVar (V "x")) (EInt 2))) \ No newline at end of file