class C t where m :: t -> Int data A ; instance C A where m = ... data B ; instance C B where m = ... f :: C t => t -> Int ; f x = m x * 2
Implementierung durch Dictionaries
data CDict t = CDict { m :: t -> Int } f :: CDict -> t -> Int ; f d x = m d x * 2