मेरा कुछ कोड ghc 7.8.2 के नवीनतम संस्करण के साथ टूट गया है।जीएचसी में भूमिकाओं के साथ टूटा कोड 7.8
मैं का उपयोग कर Data.Vector.Unbox
की पाने उदाहरणों को GeneralizedNewtypeDeriving
उपयोग कर रहा हूँ निम्नलिखित:
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)
जहां VoxelPos
मैनुअल है (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) ...
...
और इस के पिछले संस्करणों के साथ काम कर रहा था GHC। लेकिन ghc को अपग्रेड करने के बाद, मुझे निम्न त्रुटि मिलती है:
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)
जो मुझे लगता है, भूमिकाओं के अतिरिक्त है। मुझे पता है कि GeneralizedNewtypeDeriving
का उपयोग करते समय भूमिकाएं सुरक्षा में सुधार करती हैं, जो वास्तव में वाकई अच्छी है!
इसे हल करने के लिए संभावित समाधान क्या हैं? और सबसे अधिक अनुशंसित क्या है?
दस्तावेज़ों के अनुसार (http://www.haskell.org/ghc/docs/7.8.2/html/users_guide/roles.html), आपको डेटाटाइप की भूमिका बदलनी है, लेकिन यह कर सकता है केवल डेटाटाइप की परिभाषा पर किया जाना चाहिए, मुझे विश्वास है। मुझे यकीन नहीं है कि डेटा परिवारों के साथ भूमिकाएं कैसे बातचीत करती हैं - शायद आप प्रति-उदाहरण के आधार पर भूमिकाएं परिभाषित कर सकते हैं - लेकिन मुझे शक है। – user2407038
लेकिन ' एमवीक्टर 'मुझे इसे' वेक्टर 'लाइब्रेरी पर बदलना चाहिए। शायद मुझे इसे' वेक्टर 'पैकेज के रखरखाव के लिए रिपोर्ट करनी चाहिए। – LambdaStaal