These are chat archives for argonaut-io/argonaut

Apr 2016
Jan Schulte
Apr 08 2016 08:40
can i create a lens that works on a particular field in all elements of an array
right now i have this:

      val searchParamLens = jObjectPL >=>
        jsonObjectPL("elements") >=>
        jArrayPL >=>
        jsonArrayPL(0) >=>
        jObjectPL >=>
        jsonObjectPL("searchParams") >=>
but i would like to applz it the searchParams of all array objects
Sean Parsons
Apr 08 2016 08:47
I suspect @julien-truffaut would be the best person to ask on this front.
Julien Truffaut
Apr 08 2016 13:43
@janschultecom for this you will to use Traversal
unfortunately scalaz only offer Lens and Optional
but if you are fine to use monocle optics you can do it
import monocle.function._
import monocle.std.list._
val searchParams = jObjectPrism composeOptional
  index("elements") composePrism
  jArrayPrism composeTraversal
  each composePrism
  jObjectPrism composeOptional 
  index("searchParams") composePrism
Jan Schulte
Apr 08 2016 14:15
ah ok. thx a lot for the info!!
that would require the argonaut-monocle dependency only? or the monocle dependencies as well?
Julien Truffaut
Apr 08 2016 14:19
argonaut-monocle should be enough
you will get monocle transitively