我正在使用向量库并尝试编写简单的函数:
import qualified Data.Vector.Generic as GV
setCharges :: GV.Vector v Double =>
Network -> v Double -> Network
setCharges n cs = n{nodes = GV.zipWith setCharge (nodes n) cs}
使用XFlexibleContexts
ghc 接受类型声明,但在cs
varibale附近抱怨
Could not deduce (v ~ Vector)
我有
nodes n :: Data.Vector.Vector Node
setCharge :: Node -> Double -> Node
实在搞不明白,有什么问题。