[Haskell-cafe] Defining methods generically for a class
Martijn van Steenbergen
martijn at van.steenbergen.nl
Thu Jan 8 12:26:14 EST 2009
Jeff Heard wrote:
> instance Region a => Eq a where
> regiona == regionb = all $ zipWith (==) (bounds regiona) (bounds regionb)
If you want to be Haskell98 compliant, why not define regionEquals ::
Region a => a -> a -> Bool as above and use that everywhere instead of (==)?
If you insist on using the overloaded (==), then in Haskell98 you will
need to define individual Eq instances for all your custom region types.
However, you can simply define (==) = regionEquals for all those types.
Hope this helps,
More information about the Haskell-Cafe