Open i-am-tom opened 1 year ago
Ah, I think I understand what's happening here: T (Param 1 ())
doesn't resolve to the same instance as T ()
, so it can't be zipped?
Hey, Tom! Sorry, it took me some time to look into this
So, yeah, I think you are correct. What is happening is that this term gets stuck:
(Rep
(T (barbies-2.0.4.0:Data.Generics.GenericN.Param 1 ())
(barbies-2.0.4.0:Data.Generics.GenericN.Param 0 f)))
And the reason it gets stuck is that, as you say, T
is a type family, and there is no instance for T (Param 1 ())
. If T x
were instead a type (and not a type family instance), then T (Param 1 ())
would have exactly the same generic representation as T ()
, and because Param
is a newtype, it would be coercible to T ()
. This slides maybe give an idea of how this works.
Anyway, to avoid this problem, we'd need to somehow know that the first argument of T
has a nominal role so we don't tag it with Param 1
, but afaik, we don't get this exposed. Maybe @kcsongor knows a way to make this work?
Hello again 😅 Long time no see!
A slightly weird use case: this fails to derive
ConstraintsB
(but notably is fine with justFunctorB
) because of a failure to deduce someCoercible
instance.Weirder still, the error suggests that GHC made no progress on
Zip
at all here, getting immediately stuck at the datatype metadata level:I don't understand enough of the Barbies internals to give a good guess as to why, so before I do any rummaging, do you have any idea? Otherwise, I'll see whether I can figure it out.
Thanks! Tom