我正在尝试使用 Data.Vector.SEXP模块。我是 haskell 的新手。 这是我所做的和得到的:
> let x = Data.Vector.SEXP.fromList [2,3]
<interactive>:35:5:
Non type-variable argument in the constraint: Num (ElemRep s ty)
(Use FlexibleContexts to permit this)
When checking that ‘x’ has the inferred type
x :: forall s (ty :: Foreign.R.Type.SEXPTYPE).
(ty
Foreign.R.Constraints.:∈ '['Foreign.R.Type.Char,
'Foreign.R.Type.Logical, 'Foreign.R.Type.Int,
'Foreign.R.Type.Real, 'Foreign.R.Type.Complex,
'Foreign.R.Type.String, 'Foreign.R.Type.Vector,
'Foreign.R.Type.Expr, 'Foreign.R.Type.WeakRef,
'Foreign.R.Type.Raw],
Num (ElemRep s ty), Storable (ElemRep s ty),
Data.Singletons.SingI ty) =>
Data.Vector.SEXP.Vector s ty (ElemRep s ty)
我迷路了。我想要一个从列表创建 SEXP 向量的示例。
最佳答案
尝试这样做:
> let x = Data.Vector.SEXP.fromList ([2,3] :: [Int])
问题在于,在 Haskell 中,数字文字被重载,因此 [2,3]
的类型为 Num a => [a]
而不是 [ Int]
.
关于haskell - 使用 fromList 创建 SEXP 向量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38857382/