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%2FFunctor.scl;h=1c51cfab25e046a5bbd856eccf118d3821d75405;hp=6bbd359794113ce6adcd1ffd68d69f73efd0b5b1;hb=HEAD;hpb=0144ba232323a0e4f7ec8fe0681a150faafd7caf diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Functor.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Functor.scl index 6bbd35979..1c51cfab2 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Functor.scl +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Functor.scl @@ -1,23 +1,23 @@ -import "JavaBuiltin" as Java - -class Functor f where - map :: (a -> b) -> f a -> f b - -data Foo a = Foo a - -instance Functor Foo where - map f (Foo x) = Foo (f x) - -instance Functor Maybe where - map f Nothing = Nothing - map f (Just x) = Just (f x) - -data List a = Nil | Cons a (List a) - -instance Functor List where - map f Nil = Nil - map f (Cons h t) = Cons (f h) (map f t) - -main = map (map (Java.iadd 1)) (Cons Nothing (Cons (Just (1 :: Integer)) Nil)) --- +import "JavaBuiltin" as Java + +class Functor f where + map :: (a -> b) -> f a -> f b + +data Foo a = Foo a + +instance Functor Foo where + map f (Foo x) = Foo (f x) + +instance Functor Maybe where + map f Nothing = Nothing + map f (Just x) = Just (f x) + +data List a = Nil | Cons a (List a) + +instance Functor List where + map f Nil = Nil + map f (Cons h t) = Cons (f h) (map f t) + +main = map (map (Java.iadd 1)) (Cons Nothing (Cons (Just (1 :: Integer)) Nil)) +-- (Cons null (Cons 2 Nil)) \ No newline at end of file