You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the problem is that in the Nothing case, unsafeCoerce r does more than just reinterpreting CoRec fa :: CoRec f (t ': ts) into CoRec fa :: CoRec f ts, it also reinterprets the RElem dictionary.
Thus:
We start with a CoRec Identity [Int, String] containing a valid proof that String is in the second position in the list [Int, String].
The proof says that String is not in the first position, so the first restrictCoRec call casts this into a CoRec Identity [String] containing an invalid proof that String is in the second position in the list [String].
The invalid proof still says that String is not in the first position, so the second restrictCoRec call casts this into a CoRec Identity [] containing an invalid proof that String is in the second position in the list [].
Finally, matchNil errors out because it assumes that CoRec Identity '[] should be uninhabited, since it is not possible to construct a proof that String appears in the list []. But here, we have managed to construct a non-standard inhabitant by using unsafeCoerce to construct an invalid proof.
The following fails with
Exception: matchNil: impossible
Workaround: use
restrictCoRecSafe
instead ofrestrictCoRec
.The text was updated successfully, but these errors were encountered: