Fork me on GitHub
#specter
<
2016-06-27
>
conaw03:06:45

Lets say I have a tree, and I want to select all of the nodes n levels away from the root following a particular path, is there a smart way to define a navigator that would repeat n times?

conaw03:06:31

(select [(repeat-path [:children ALL] 4)] tree)

conaw03:06:42

I’ve noticed some talk of stateful navigators in here but wasn’t paying close attention, is this a case for that?

conaw03:06:10

(declarepath deeper [i])

(defpathedfn deeper [i]
  (if (= 0 i)
    (keypath i)
    (deeper (dec i))))


(select [(deeper 1)] [0 1 2 3])

conaw03:06:27

ok, found an answer

(declarepath repeat-path [walk-path end-path i])

(defpathedfn repeat-path [walk-path end-path i]
  (if (= 0 i)
    end-path
    [walk-path (repeat-path walk-path end-path (dec i))]))


(select [(repeat-path [:node/_children ALL] :db/id 3)] ptest)

conaw04:06:01

other question, Figwheel doesn’t seem to like that I am declaring a path and then redefining it this way,

Figwheel: Compile Warning - repeat-path at line 105 is being replaced at line 107 
anything to be done about this?

nathanmarz09:06:28

@conaw: don't call declarepath there, that's only for usage with providepath

nathanmarz09:06:39

@conaw: the defpathedfn call works fine without it

conaw09:06:06

yup, discovered that, my bad not updating

conaw09:06:21

This has made my life so much easier by the way. Today was an absolute joy because of it. Thank you.

nathanmarz09:06:38

good to hear

jjcomer16:06:54

Has anyone had any issues using specter in an AOT’d uberjar? I’m using it to pull data out of my immutant request. It works fine when running with lein run, but when I run the uberjar, it errors when using the request with: java.lang.IllegalArgumentException: No implementation of method: :get_cell of protocol: #'com.rpl.specter.impl/PMutableCell found for class: clojure.lang.Var$Unbound

nathanmarz17:06:37

a few people have reported similar issues, I haven't looked into it

jjcomer17:06:57

Immutant uses a immutant.web.internal.ring.LazyMap for its requests

nathanmarz17:06:56

I'm not seeing the relevance of that

jjcomer17:06:26

Nor I 🙂

adambros20:06:01

i can confirm that error, although it came up from something other than immutant

nathanmarz20:06:46

@adambros @jjcomer with what versions of clojure/specter did you see those errors?

adambros20:06:27

iirc clj 1.8 and specter 0.11.0

adambros20:06:02

correction: specter 0.11.2

nathanmarz20:06:27

cool, thanks

adambros20:06:34

im pretty sure i didnt want unbound vars in my data, but it would fail on that if i typo’d a symbol

nathanmarz21:06:58

oh I think I know what the problem might be

nathanmarz21:06:28

@jjcomer @adambros do you get the error with specter 0.10.0?

adambros21:06:46

i dont, which is why i havent upgraded yet

nathanmarz21:06:17

ok, that supports my hypothesis

nathanmarz21:06:27

@adambros @jjcomer I was able to reproduce it and fix it, give 0.12.0-SNAPSHOT a shot and let me know if it fixes it

nathanmarz21:06:42

just deployed 0.12.0-SNAPSHOT to clojars

angusiguess22:06:43

@nathanmarz: I built a small repro and just tried with 0.12.0-SNAPSHOT and it worked.