]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/TypeClassBug1.scl
(refs #7307) Added features field to SCL module header
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / TypeClassBug1.scl
1 import "JavaBuiltin" as Java
2
3 importJava "org.simantics.scl.runtime.Lists" where
4     foldl :: (a -> b -> a) -> a -> [b] -> a
5
6 class Additive a where
7     zero :: a
8     (+)  :: a -> a -> a    
9     
10     sum  :: [a] -> a
11     sum = foldl (+) zero    
12     
13 instance (Additive a, Additive b, Additive c) => Additive (a, b, c) where
14     zero = (zero, zero, zero)
15     (a0, b0, c0) + (a1, b1, c1) = (a0+a1, b0+b1, c0+c1)
16     
17 main = "OK"
18 --
19 OK