当我尝试这个时:
import GHC.Generics (Generic)
import Control.DeepSeq (NFData(..))
import Data.Vector.Generic (Vector)
data Entry a = Entry !Bool a
deriving (Generic, NFData)
-- The variable @v@ is meant to be instantiated with a 'Vector'
-- type. Most operations for the type have a @Vector v (Entry a)@
-- constraint.
newtype DenseIntMap v a = DenseIntMap (v (Entry a))
instance NFData (v (Entry a)) => NFData (DenseIntMap v a) where
rnf (DenseIntMap va) = rnf va
...我收到此错误:
/Users/casillas/GitHub/tau-sigma/src/TauSigma/Util/DenseIntMap.hs:53:10:
Constraint is no smaller than the instance head
in the constraint: Vector v (Entry a)
(Use UndecidableInstances to permit this)
In the instance declaration for ‘NFData (DenseIntMap v a)’
/Users/casillas/GitHub/tau-sigma/src/TauSigma/Util/DenseIntMap.hs:53:10:
Constraint is no smaller than the instance head
in the constraint: NFData (v (Entry a))
(Use UndecidableInstances to permit this)
In the instance declaration for ‘NFData (DenseIntMap v a)’
使用UndecidableInstances
确实可以让它消失,但我对使用该扩展程序持谨慎态度。在这种情况下,还有其他方法可以使事情正常进行吗?(最好不要过多地改变类型。)