class Foo a where foo :: a class (Foo a) => Bar a where bar :: a instance Bar Double where foo x = x bar x = x main = foo 3.0 + bar 4.0 -- 7.0