
20 Aug
2013
20 Aug
'13
8:20 a.m.
On 20/08/13 12:13, TP wrote:
{-# LANGUAGE MultiParamTypeClasses #-}
class Bar a where bar :: a -> Int
class FooBar a b where foobar :: Bar a => a -> b -> Int foobar avalue bvalue = bar avalue
instance Bar Int where bar i = 5 instance FooBar Int Int
main = do print $ bar (4::Int) print $ foobar (5::Int) (2::Int)
It might be better to make Bar a superclass of FooBar, class Bar a => FooBar a b where foobar :: a -> b -> Int foobar a b = bar a Then the compiler knows that every instance of FooBar also requires an instance of Bar. Twan