summaryrefslogtreecommitdiff
path: root/demo/tcSum.ur
diff options
context:
space:
mode:
Diffstat (limited to 'demo/tcSum.ur')
-rw-r--r--demo/tcSum.ur9
1 files changed, 9 insertions, 0 deletions
diff --git a/demo/tcSum.ur b/demo/tcSum.ur
new file mode 100644
index 00000000..53679116
--- /dev/null
+++ b/demo/tcSum.ur
@@ -0,0 +1,9 @@
+fun sum (t ::: Type) (_ : num t) (fs ::: {Unit}) (x : $(mapUT t fs)) =
+ foldUR [t] [fn _ => t]
+ (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] n acc => n + acc)
+ zero [fs] x
+
+fun main () = return <xml><body>
+ {[sum {A = 0, B = 1}]}<br/>
+ {[sum {C = 2.1, D = 3.2, E = 4.3}]}
+</body></xml>