specter

Latest version: 1.1.3
punit-naik 2018-06-02T14:04:06.000101Z

Hi Guys! I was just starting out with Specter. I had a few questions. 1. Are there error-handling functions implemented inside specter? Can I get errors as to where my navigator failed? 2. Can it work with lazy seqs? Will the laziness be preserved? 3. Can we use reducers in setval?

nathanmarz 2018-06-02T14:09:42.000094Z

@punit-naik there's no particular error handling done by specter

nathanmarz 2018-06-02T14:09:54.000100Z

I can usually tell where I messed up a path by looking at the stack trace

nathanmarz 2018-06-02T14:10:42.000044Z

specter will never produce a lazy output

nathanmarz 2018-06-02T14:11:27.000115Z

though using select-first can accomplish many of the same things since it terminates navigation as soon as it encounters a matching value

nathanmarz 2018-06-02T14:11:35.000052Z

don't know what you mean by #3

nathanmarz 2018-06-02T15:14:38.000009Z

@punit-naik the most efficient way to reduce over navigated values is with traverse

👍 1
nathanmarz 2018-06-02T15:15:42.000144Z

timing a single invocation tells you absolutely nothing, since neither specter nor the jvm have had a chance to optimize that callsite

nathanmarz 2018-06-02T15:16:01.000016Z

use criterium for benchmarking

nathanmarz 2018-06-02T15:16:54.000121Z

I think you want (transform [ALL (must :a)] inc [{:a 1 :b 2} {:a 2 :b 1} {:b 3}]) for that code

nathanmarz 2018-06-02T15:21:13.000095Z

your path says to navigate to that key

nathanmarz 2018-06-02T15:21:34.000044Z

it's doing exactly what you instructed

nathanmarz 2018-06-02T15:22:28.000132Z

it's like doing (update {} :a inc)

punit-naik 2018-06-02T15:24:36.000039Z

okay.