]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Seq.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / tests / org / simantics / scl / compiler / tests / scl / Seq.scl
diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Seq.scl b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/Seq.scl
new file mode 100644 (file)
index 0000000..4b60e52
--- /dev/null
@@ -0,0 +1,19 @@
+import "Prelude"\r
+import "JavaBuiltin" as Java\r
+\r
+class Seq seq el where\r
+    myLength :: seq -> Integer\r
+    myGet :: seq -> Integer -> el\r
+\r
+instance (b ~ Character) => Seq String b where\r
+    myLength = Java.method "length"\r
+    myGet = Java.method "charAt"\r
+    \r
+instance (b ~ a) => Seq [a] b where\r
+    myLength = Java.method "size"\r
+    myGet = Java.method "get"\r
+\r
+//main :: (Character, String)\r
+main = (myGet "abc" 1, myGet ["a", "b", "c"] 1)\r
+--\r
+(b,b)
\ No newline at end of file