summaryrefslogtreecommitdiff
path: root/test/genericimpl.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-31 22:18:17 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-31 22:49:31 -0800
commit128470e404d843b3d71c5837cac05d4d4203bd66 (patch)
tree267d7879867aebd35a7f8203d0ff9f77fb9238f0 /test/genericimpl.myr
parentfb8753c942a8d06926977d221d5c89c3a867fa29 (diff)
downloadmc-128470e404d843b3d71c5837cac05d4d4203bd66.tar.gz
Add support for generic impls.
You can now implement generic shit like iterators.
Diffstat (limited to 'test/genericimpl.myr')
-rw-r--r--test/genericimpl.myr33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/genericimpl.myr b/test/genericimpl.myr
new file mode 100644
index 0000000..ef8e094
--- /dev/null
+++ b/test/genericimpl.myr
@@ -0,0 +1,33 @@
+use std
+
+trait gimpl @a =
+ desc : (x : @a -> byte[:])
+;;
+
+impl gimpl int =
+ desc = {x
+ -> "int"
+ }
+;;
+
+impl gimpl byte[:] =
+ desc = {x
+ -> "string"
+ }
+;;
+
+impl gimpl @a =
+ desc = {x
+ -> "@a"
+ }
+;;
+
+impl gimpl @b[:] =
+ desc = {x
+ -> "@a[:]"
+ }
+;;
+
+const main = {
+ std.put("{} {} {} {}\n", desc(123), desc("foo"), desc('x'), desc([true][:]))
+}