Commit d5442607 authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Testcase for Coercible and newtype families (#8548)

parent 6f49522e
{-# LANGUAGE RoleAnnotations, StandaloneDeriving, FlexibleContexts, UndecidableInstances, GADTs #-}
{-# LANGUAGE RoleAnnotations, StandaloneDeriving, FlexibleContexts, UndecidableInstances, GADTs, TypeFamilies #-}
import GHC.Prim (Coercible, coerce)
import Data.Monoid (mempty, First(First), Last())
......@@ -31,6 +31,10 @@ data Oracle where Oracle :: Coercible (Fix (Either Age)) (Fix (Either Int)) =>
foo :: Oracle -> Either Age (Fix (Either Age)) -> Fix (Either Int)
foo Oracle = coerce
-- This ensures that Coercible looks into newtype instances (#8548)
data family Fam k
newtype instance Fam Int = FamInt Bool deriving Show
main = do
print (coerce $ one :: Age)
print (coerce $ age :: Int)
......@@ -58,6 +62,9 @@ main = do
print (coerce $ (FixEither (Left age) :: FixEither Age) :: Either Int (FixEither Int))
print (coerce $ (Left one :: Either Int (FixEither Age)) :: FixEither Age)
print (coerce $ True :: Fam Int)
print (coerce $ FamInt True :: Bool)
foo `seq` return ()
......
......@@ -16,3 +16,5 @@ Left ()
Fix (Left ())
Left 1
FixEither (Left (Age 1))
FamInt True
True
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment