1 import "JavaBuiltin" as Java
4 map :: (a -> b) -> f a -> f b
8 instance Functor Foo where
9 map f (Foo x) = Foo (f x)
11 instance Functor Maybe where
12 map f Nothing = Nothing
13 map f (Just x) = Just (f x)
15 data List a = Nil | Cons a (List a)
17 instance Functor List where
19 map f (Cons h t) = Cons (f h) (map f t)
21 main = map (map (Java.iadd 1)) (Cons Nothing (Cons (Just (1 :: Integer)) Nil))
23 (Cons null (Cons 2 Nil))