Closed mgsloan closed 4 years ago
CmpType
only works for two things of the same kind. It probably makes sense to leave it stuck otherwise, but in that case it hits the default case in CmpType
which gives a bad error message in this case. Nice catch. Any idea what the right solution is here?
No idea what the right solution is, without digging in to the problem further.
Proxy "Hmm"
and Proxy Int
have the same kind, *
, so I expected it to work.
Is there an implementation reason for having CmpType
require the types to be of the same kind? On one hand I see the analogy to Ord, and so the same kind restriction makes sense. On the other hand, comparing types with polykinded arguments, as in this example, seems to require that type comparison handles differing kinds.
Interesting. What happens if you comment out the error case from CmpType
?
I think I figured it out! I added some tracing to the plugin, and it looks like splitTyConApp_maybe
is failing on Symbol
. The tests which involve symbols pass because they don't involve the plugin, instead using the CmpType a a = 'Eq
and CmpType (a :: Symbol) b = CmpSymbol a b
cases.
I have some other reasons to dig into this code, so I will go ahead and try to fix.
If I add the following to
cmptype/test/ShouldTypecheck.hs
I get the error
Without the addition of
testWat
, the test passes fine for me.Doing some code sleuthing, it looks like this occurs when
CmpTypeImpl
is stuck. I'm not sure why this is. Before I looked at the plugin implementation, I figured that it is due to comparing types with polykinded arguments, where the kinds differ. However, after looking at the implementation I do not see how this would cause a problem.