]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/BinaryOperators1.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / BinaryOperators1.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/BinaryOperators1.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/BinaryOperators1.scl
new file mode 100644 (file)
index 0000000..86263c9
--- /dev/null
@@ -0,0 +1,25 @@
+import "Prelude"\r
+\r
+data E = E String\r
+\r
+instance Additive E where\r
+    zero = E "0"\r
+    E a + E b = E ("(" + a + "+" + b + ")")\r
+    \r
+instance Ring E where\r
+    one = E "1"\r
+    neg (E a) = E ("(-" + a + ")")\r
+    E a - E b = E ("(" + a + "-" + b + ")")\r
+    E a * E b = E ("(" + a + "*" + b + ")") \r
+    fromInteger x = E (show x)\r
+\r
+eToString (E a) = a\r
+\r
+a = E "a"\r
+b = E "b"\r
+c = E "c"\r
+d = E "d"\r
+\r
+main = eToString (-a + b + (-c*d))\r
+--\r
+(((-a)+b)+(-(c*d))) 
\ No newline at end of file