在我之前关于Data.Vector.Generic.Vector
实例的问题之后,我开始想知道,为什么
zipWith :: (Vector v a, Vector v b, Vector v c)
=> (a -> b -> c) -> v a -> v b -> v c
zipWith f xs ys = unstream (Stream.zipWith f (stream xs) (stream ys))
并不是
zipWith :: (GV.Vector v1 a, GV.Vector v2 b, GV.Vector v3 c)
=> (a -> b -> c) -> v1 a -> v2 b -> v3 c
zipWith f xs ys = unstream (Stream.zipWith f (stream xs) (stream ys))
?
第二个编译得很好。是否有任何特殊原因将所有此类功能限制在一个实例中?因为对我来说
v1 = Data.Vector.fromList [1,2,3,4,5]
v2 = Data.Vector.Unboxed.fromList [6,7,8,9] :: Data.Vector.Unboxed.Vector Int
v3 = foo (*) v1 v2 :: Data.Vector.Unboxed.Vector Int
v4 = foo (*) v1 v2 :: Data.Vector.Vector Int
看起来更“通用”。