-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Description
Some of my code is broken with the newest version of ghc (7.8.2).
I'm using GeneralizedNewtypeDeriving to deriving instances of Data.Vector.Unbox using the following:
data VoxelPos = VoxelPos
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
{-# UNPACK #-} !Int
deriving (Show, Eq, Ord)
newtype FacePos = FacePos VoxelPos deriving ( Eq, Hashable, NFData, G.Vector U.Vector, M.MVector U.MVector, U.Unbox)
where VoxelPos have manual rolled instances using (Int, Int, Int):
newtype instance U.MVector s VoxelPos = MV_VoxelPos (U.MVector s (Int, Int, Int))
newtype instance U.Vector VoxelPos = V_VoxelPos (U.Vector (Int, Int, Int))
instance U.Unbox VoxelPos
instance M.MVector U.MVector VoxelPos where
basicLength (MV_VoxelPos v) ...
...
and this was working with the previous versions of ghc. But after upgrading ghc, I get the following error:
Could not coerce from ‘U.MVector s (Int, Int, Int)’ to ‘U.MVector
s FacePos’
because the second type argument of ‘U.MVector’ has role Nominal,
but the arguments ‘(Int, Int, Int)’ and ‘FacePos’ differ
arising from the coercion of the method ‘M.basicLength’ from type
‘forall s. U.MVector s VoxelPos -> Int’ to type
‘forall s. U.MVector s FacePos -> Int’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (M.MVector U.MVector FacePos)
which, I think, is because of addition of roles. I know that roles improves safety when using GeneralizedNewtypeDeriving which is, of course, really good!
What are the possible solutions to solve this?
It seems necessary to enforce the role of MVector, something like this:
type role MVector _ representational
Metadata
Metadata
Assignees
Labels
No labels