-
-
Save mstksg/f0568e8476b4e6075ab1d06376d0d930 to your computer and use it in GitHub Desktop.
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
import Data.Coercible | |
newtype KM a x = KM (Maybe a) | |
newtype K1 a x = K1 a | |
data Id x = Id x | |
newtype IdF f x = IdF (f x) | |
data IdF' f x = IdF' (f x) | |
-- this works: K1 (Maybe a) x is coercible with KM a x | |
coerce (K1 (Just True)) :: KM Bool () | |
-- this also works, if we wrap it in a non Higher Kinded data type | |
coerce (Id (K1 (Just True))) :: Id (KM Bool ()) | |
-- this also works if we wrap it in a higher kinded newtype | |
coerce (IdF (K1 (Just True))) :: IdF (KM Bool) () | |
-- but this doesn't work if we wrap it in higher-kinded data decl | |
coerce (IdF' (K1 (Just True))) :: IdF' (KM Bool) () | |
{- | |
• Couldn't match representation of type ‘K1 (Maybe Bool)’ | |
with that of ‘KM Bool’ | |
-} | |
-- note the error is referring to the functor and not the fully saturated type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment