Re: [Haskell-cafe] Defining methods generically for a class

That's probably the best thing to do, yes. The purpose of doing so
was for Data.List.delete, but I see now there's a Data.List.deleteBy,
so I can use the regionEquals function as my equality predicate.
On Thu, Jan 8, 2009 at 12:26 PM, Martijn van Steenbergen
Hi Jeff,
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,
Martijn.
participants (1)
-
Jeff Heard