]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/OverloadedArithmetic1.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / tests / org / simantics / scl / compiler / tests / scl / OverloadedArithmetic1.scl
diff --git a/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/OverloadedArithmetic1.scl b/bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/scl/OverloadedArithmetic1.scl
new file mode 100644 (file)
index 0000000..de083e8
--- /dev/null
@@ -0,0 +1,17 @@
+import "JavaBuiltin" as Java\r
+\r
+infixl 6 (+)\r
+\r
+class Additive a where \r
+    (+)  :: a -> a -> a    \r
+    \r
+instance Additive Double where\r
+    x + y = Java.dadd x y\r
+\r
+instance Additive Integer where\r
+    x + y = Java.iadd x y\r
+    \r
+main = ((1.0 :: Double)+(2.0 :: Double),(3::Integer)+(4::Integer))\r
+--\r
+(3.0,7)\r
+\r