
On Thu, Oct 05, 2006 at 08:58:28PM +0200, Bjorn Bringert wrote:
- When deriving instances of multi-parameter type classes (again non- standard), the newtype for which the deriving is made must be the last argument to the class. If the syntax were "deriving (Class T1 ... Tn)", it might not be clear to the reader what type the deriving is for.
I have run into this restriction multiple times, and since it only arises due to the syntax, it would be good to fix that too with any proposed change to the deriving syntax. A related issue is that you currently cannot 'co-derive' a multiparameter typeclass among multiple newtype definitions. such as the following:
class SetLike m k where insert :: k -> m -> m ...
instance SetLike IntSet Int where ...
newtype Id = Id Int
newtype IdSet = IdSet IntSet
now, ideally you should be able to derive MapLike (IdMap v) Id v, but there is no way to do it with the current syntax. if we make the instance we are using to derive the newtypes instance from explicit however, it solves both problems nicely. allow toplevel definitions like the following:
deriving (SetLike IntSet Int => SetLike IdSet Id)
John -- John Meacham - ⑆repetae.net⑆john⑈