Conversation
|
Fixes #514 |
|
I'll review this properly shortly, but I have a minor syntax comment: I think it's a little weird to start the declaration with
|
|
Actually, that distinction probably shouldn't be allowed/necessary, should it? The newtype version of a |
|
I think there needs to be some distinction, since for example, derived |
|
Well, I was thinking about that too. Their implementation differs, but are they not the same? I would assume the derived instance would be along the lines of: newtype Foo = Foo String
instance eqFoo :: Eq Foo where
eq (Foo a) (Foo b) = eq a bWhich when you remove the newtype unwrapping is identical? |
|
Oh right, that's true. I was thinking the derived instances would compare the deep structure of the two values, but that's not right. I'm fine with |
|
@garyb Updated, how's this? I'd prefer to keep the syntax for derived newtype instances separate for now, since we don't know if all future derivable instances will be the same as their newtype-derived counterparts. |
|
|
||
| forValues (TypeClassDictionary c _ _) = mconcat (map f (constraintArgs c)) | ||
| forValues (SuperClassDictionary _ tys) = mconcat (map f tys) | ||
| forValues (DeferredDictionary _ tys) = mconcat (map f tys) |
There was a problem hiding this comment.
Isn't this just foldMap btw?
Fair enough. Should we explicitly disallow it for |
I'm not sure. The instances for I'd rather not make a special case for any particular class actually. |
|
My worry was that |
|
|
This adds
newtype instancesyntax, which implements instances for newtypes by simply casting the corresponding dictionary for the type under the newtype.