-
-
Save Lysxia/f082a3af9472511b5dcec045f945348b to your computer and use it in GitHub Desktop.
GHC 8.2 bug where Coercible is not symmetric (on GHC 8.0, 8.2, somehow fixed on 8.4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Coercible not symmetric on GHC 8.0, 8.2, somehow fixed on 8.4 | |
{-# LANGUAGE | |
AllowAmbiguousTypes, | |
FlexibleContexts, | |
ScopedTypeVariables, | |
TypeFamilies, | |
TypeApplications | |
#-} | |
module S where | |
import GHC.Generics | |
import Data.Coerce | |
type family F a :: * -> * | |
-- Type checks | |
e :: forall a b x. (Coercible (F a x) (F b x)) => F a x -> F b x | |
e = coerce @(F a x) @(F b x) | |
-- Doesn't type check | |
f :: forall a b x. (Coercible (F b x) (F a x)) => F a x -> F b x | |
f = coerce @(F a x) @(F b x) | |
{- | |
S.hs:24:5: error: | |
• Could not deduce: Coercible (F a x) (F b x) | |
arising from a use of ‘coerce’ | |
from the context: Coercible (F b x) (F a x) | |
bound by the type signature for: | |
f :: Coercible (F b x) (F a x) => F a x -> F b x | |
at S.hs:23:1-64 | |
NB: ‘F’ is a type function, and may not be injective | |
• In the expression: coerce @(F a x) @(F b x) | |
In an equation for ‘f’: f = coerce @(F a x) @(F b x) | |
• Relevant bindings include | |
f :: F a x -> F b x (bound at S.hs:24:1) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment