
You *can* do this, but it's often not so concise. When the type constructor
has parameters, you need to pin them down using ScopedTypeVariables. So you
end up needing to give a signature for the method type in order to bring
into scope variables you then use in the argument to coerce. If you have
newtype Foo f a = Foo (Foo f a)
then you may need
instance Bar f => Bar (Foo f) where
bah = coerce (bah @ f @ a)
:: forall a . C a => ...
to pin down the C instance.
If you don't want to use explicit type application (e.g., you're using a
library that does not claim to have stable type argument order), things get
even more verbose.
On Jan 8, 2017 11:32 PM, "Joachim Breitner"
Hi,
just responding to this one aspect:
Am Sonntag, den 08.01.2017, 21:16 -0500 schrieb David Feuer:
but using defaults for the others would give poor implementations. To cover this case, I think it would be nice to add per-method GND-deriving syntax. This could look something like
instance C T where deriving f g = ....
Assuming newtype T = MkT S
You can achieve this using
instance C T where f = coerce (f @F) g = ....
(which is precisely what GND does), so I don’t think any new syntax is needed here.
Greetings, Joachim
-- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users