Last active
August 29, 2015 14:21
-
-
Save aavogt/936b03b8a7875e690649 to your computer and use it in GitHub Desktop.
roles are more restrictive (but not for newtype instance)
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 KindSignatures #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import qualified Data.Vector as V | |
import qualified Data.Vector.Mutable as VM | |
import qualified Data.Vector.Generic as G | |
import Data.Coerce | |
import Control.Monad.Primitive | |
import Foreign.C | |
data family MVec (v :: * -> *) :: * -> * -> * | |
newtype instance MVec V.Vector a b = VM_Vector (VM.MVector a b) | |
coerce_was_bad :: MVec V.Vector RealWorld Double -> MVec V.Vector RealWorld CDouble | |
coerce_was_bad = coerce | |
{- this error only happens if the MVec instance was a Data instance: | |
Could not coerce from ‘MVec V.Vector RealWorld Double’ to ‘MVec | |
V.Vector RealWorld CDouble’ | |
because the third type argument of ‘MVec’ has role Nominal, | |
but the arguments ‘Double’ and ‘CDouble’ differ | |
arising from a use of ‘coerce’ | |
In the expression: coerce | |
In an equation for ‘coerce_bad’: coerce_bad = coerce | |
-} | |
coerce_good :: G.Mutable V.Vector RealWorld Double -> G.Mutable V.Vector RealWorld CDouble | |
coerce_good = coerce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment