Y at-il une connexion implémentée entre propositional et promoted égalité?Y a-t-il un lien entre `a: ~: b` et` (a: == b): ~: True`?
Disons que je
prf :: x :~: y
portée pour certains Symbol
s; par modèle correspondant à ce sujet étant Refl
, je peux transformer cela en
prf' :: (x :== y) :~: True
comme ceci:
fromProp :: (KnownSymbol x, KnownSymbol y) => x :~: y -> (x :== y) :~: True
fromProp Refl = Refl
Mais qu'en l'autre sens? Si je tente
toProp :: (KnownSymbol x, KnownSymbol y) => (x :== y) :~: True -> x :~: y
toProp Refl = Refl
alors tout ce que je reçois est
• Could not deduce: x ~ y
from the context: 'True ~ (x :== y)
Bien sûr, 'toProp _ = unsafeCoerce Refl'. 'sameSymbol' est défini de cette façon, donc je doute que vous puissiez faire mieux. – user3237465
Vous pouvez également écrire 'toProp Refl = fromJust $ sameSymbol (Proxy :: Proxy x) (Proxy :: Proxy y)' mais cela n'est que légèrement meilleur que d'utiliser 'unsafeCoerce'. – user2407038