X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=tests%2Forg.simantics.scl.compiler.tests%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftests%2Fscl%2FTypeClassBug2.scl;h=b20ade0acab838d6794b64d82cf4a77e82aad676;hp=a341ba6b2a0962a2888b321481bba39c39511b4f;hb=172abed5dbf73c1304a7a95bb8504ea293556948;hpb=2a8d452434358e28cb826744bc01755a46455afd diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/TypeClassBug2.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/TypeClassBug2.scl index a341ba6b2..b20ade0ac 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/TypeClassBug2.scl +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/TypeClassBug2.scl @@ -1,54 +1,54 @@ -data Foo1 a = Foo1 a -data Foo2 a = Foo2 a - -foo1 :: Foo1 a -> a -foo1 (Foo1 x) = x - -foo2 :: Foo2 a -> a -foo2 (Foo2 x) = x - -class Makeable s where - make :: a -> s a - -instance Makeable Foo1 where - make = Foo1 - -instance Makeable Foo2 where - make = Foo2 - -class (Makeable f) => Foo f where - foo :: f a -> a - -class (Makeable b) => Bar b where - bar :: b a -> a - -class (Makeable b) => Baz b where - baz :: b a -> a - -class (Makeable b) => Bim b where - bim :: b a -> a - -instance Foo Foo1 where - foo = foo1 - -instance Bar Foo2 where - bar = foo2 - -instance (Bar b) => Baz b where - baz = bar - -instance Bim Foo1 where - bim = foo1 - -instance (Baz b) => Bim b where - bim = baz - -doFoo1 (Foo1 x) = x -doFoo2 (Foo2 x) = x - -useBim :: Bim b => (forall a. b a -> a) -> a -> [a] -useBim doit x = [doit (make x), bim (make x :: Foo1 a)] - -main = "OK" --- -"OK" +data Foo1 a = Foo1 a +data Foo2 a = Foo2 a + +foo1 :: Foo1 a -> a +foo1 (Foo1 x) = x + +foo2 :: Foo2 a -> a +foo2 (Foo2 x) = x + +class Makeable s where + make :: a -> s a + +instance Makeable Foo1 where + make = Foo1 + +instance Makeable Foo2 where + make = Foo2 + +class (Makeable f) => Foo f where + foo :: f a -> a + +class (Makeable b) => Bar b where + bar :: b a -> a + +class (Makeable b) => Baz b where + baz :: b a -> a + +class (Makeable b) => Bim b where + bim :: b a -> a + +instance Foo Foo1 where + foo = foo1 + +instance Bar Foo2 where + bar = foo2 + +instance (Bar b) => Baz b where + baz = bar + +instance Bim Foo1 where + bim = foo1 + +instance (Baz b) => Bim b where + bim = baz + +doFoo1 (Foo1 x) = x +doFoo2 (Foo2 x) = x + +useBim :: Bim b => (forall a. b a -> a) -> a -> [a] +useBim doit x = [doit (make x), bim (make x :: Foo1 a)] + +main = "OK" +-- +"OK"