Created
April 20, 2017 13:59
-
-
Save kosmikus/3660d79bdab60eb6e7e32b5a30dd89a2 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
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE RoleAnnotations #-} | |
module CoerceTest where | |
import Data.Coerce | |
type role A phantom | |
data A a = MkA Int | |
-- works (CORRECT) | |
fooA :: Coercible o (A a) => o -> () | |
fooA _ = () | |
type role B representational | |
data B a = MkB Int | |
{- | |
-- does not work (CORRECT) | |
fooB :: Coercible o (B a) => o -> () | |
fooB _ = () | |
-} | |
type role C representational | |
newtype C a = MkC Int | |
-- works, but should not | |
fooC :: Coercible o (C a) => o -> () | |
fooC _ = () | |
newtype D a = MkD a | |
{- | |
-- does not work (CORRECT) | |
fooD :: Coercible o (D a) => o -> () | |
fooD _ = () | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment