[Haskell-cafe] Inheritance and Wrappers
Stephen Tetley
stephen.tetley at gmail.com
Tue Feb 1 13:18:53 CET 2011
On 1 February 2011 11:47, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
>
> So, is there a way to declare an AbGroup instance for the types with num
> instances only?
No - as Henning says its then no more useful than simply a function:
add :: (Num u) => a -> a -> a
add = (+)
'Overarching instances' i.e. classes with one implementation are a
design flaw, not a virtue [*] so this hypothetical extension isn't
welcome...
{-# LANGUAGE OverarchingInstances #-}
[*] Of course, there might be some valid cases for things in Oleg
Kiselyov's typecast style, but modelling numericals doesn't look like
one of them.
More information about the Haskell-Cafe
mailing list