Aeson 值的嵌套向量是否有 AsValue 实例?
Is there an AsValue instance for nested Vectors of Aeson Values?
我正在尝试感受 aeson
软件包。我是不是用错了 Lens
API?
> :t bt ^? _Array
bt ^? _Array :: Maybe (vector-0.10.12.2:Data.Vector.Vector Value)
> :t bt ^? _Array . nth 0 . _Array
<interactive>:1:16:
No instance for (AsValue
(vector-0.10.12.2:Data.Vector.Vector Value))
arising from a use of ‘nth’
In the first argument of ‘(.)’, namely ‘nth 0’
In the second argument of ‘(.)’, namely ‘nth 0 . _Array’
In the second argument of ‘(^?)’, namely ‘_Array . nth 0 . _Array’
您正在使用 nth
,这是一个组合器,旨在让您在直接遍历 JSON 值时更容易工作。但是,您使用的是值向量。在这种情况下,您应该使用 ix 0
而不是 nth 0
.
我正在尝试感受 aeson
软件包。我是不是用错了 Lens
API?
> :t bt ^? _Array
bt ^? _Array :: Maybe (vector-0.10.12.2:Data.Vector.Vector Value)
> :t bt ^? _Array . nth 0 . _Array
<interactive>:1:16:
No instance for (AsValue
(vector-0.10.12.2:Data.Vector.Vector Value))
arising from a use of ‘nth’
In the first argument of ‘(.)’, namely ‘nth 0’
In the second argument of ‘(.)’, namely ‘nth 0 . _Array’
In the second argument of ‘(^?)’, namely ‘_Array . nth 0 . _Array’
您正在使用 nth
,这是一个组合器,旨在让您在直接遍历 JSON 值时更容易工作。但是,您使用的是值向量。在这种情况下,您应该使用 ix 0
而不是 nth 0
.