instantiating visible parameters in when deriving instances
Ryan Scott
ryan.gl.scott at gmail.com
Mon Mar 28 15:12:21 UTC 2016
> I don't really expect any of the TypeInType stuff to work with the deriving machinery.
I do! And we can make -XDeriveFunctor work well with -XTypeInType
regardless of which option is picked, so keep that in mind.
> I think that, at the moment, for a normal deriving clause, GHC never adds in constraints (I might be wrong on this).
GHC does add constraints in some cases. Here's a less dangerous-looking example:
data T (a :: k) = T deriving Functor
=>
instance Functor T
The generated instance very subtly constraints k to be *. The
difference in this example, however, is that k is not visible, so it
feels less harmful to constrain it.
> I don't know if StandaloneDeriving works with DeriveFunctor or not
It does. -XStandaloneDeriving works with any flavor of deriving out
there, and it's a great backdoor to get around sticky deriving issues
like this (e.g., if a derived instance context would require
undecidable typechecking, we bail out and tell the user to try again
with -XStandaloneDeriving).
I don't have a strong opinion on whether option 1, 2, or 3 is best,
but if we pick option 1 or 2, I request that the error message tell
the user to try -XStandaloneDeriving.
Ryan S.
More information about the ghc-devs
mailing list