import "JavaBuiltin" as Java (+) = Java.iadd class Foo a where foo :: a -> Integer /* class (Foo a) => Bar a where bar :: a -> Integer */ instance Foo Integer where foo x = x+1 /* instance Bar Integer where bar x = x+2 */ data X a = X a instance (Foo a) => Foo (X a) where foo (X a) = foo a /* instance (Bar a) => Bar (X a) where bar (X a) = bar a*/ main = foo (X (1 :: Integer)) // + bar (X (2 :: Integer)) -- 2