0

I'm trying to get the feel of aeson package. Am I using its Lens API incorrectly?

> :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’
sevo
  • 4,559
  • 1
  • 15
  • 31

1 Answers1

2

You're using nth which is a combinator designed to make it easier to work when you are directly traversing a JSON value. However, you're working with a vector of values. In this case, you should use ix 0 rather than nth 0.

ocharles
  • 6,172
  • 2
  • 35
  • 46