Fork me on GitHub
#specter
<
2017-10-06
>
gdeer8115:10:41

is AFTER-ELEM used in selections or is just primarily used with setval ? I want to make sure my koans cover possible use cases unless it doesn't make sense.

gdeer8115:10:34

also, I watched the talk and was excited about specter keeping the collection type the same so I was surprised when I saw this (setval AFTER-ELEM 2 #{1 2}) => (1 2 2)

gdeer8115:10:03

the set was turned into a list

gdeer8115:10:03

it does the same thing for a map

gdeer8115:10:10

I tried to pass a k/v pair to AFTER-ELEM as two args and go a wrong number of args error

gdeer8115:10:43

when I put the k/v pair as a map it just turned the original map into a vector, added it to a list and then added my k/v argument as a separate map in the list like this: (setval AFTER-ELEM {:friend "Mary"} {:name "Paul"}) => ([:name "Paul"] {:friend "Mary"}) so since the result isn't treated like a map you don't need k/v pair balance (setval AFTER-ELEM "Mary" {:name "Paul"}) => ([:name "Paul"] "Mary")

gdeer8115:10:42

I just want to make sure I'm not documenting nonsense cases

nathanmarz15:10:14

@gdeer81 AFTER-ELEM is only intended for transformations

nathanmarz15:10:34

it doesn't make sense in the context of a set

nathanmarz15:10:46

to add a single element to a set most efficiently use NONE-ELEM

nathanmarz16:10:12

likewise, it doesn't make sense in the context of a map

nathanmarz16:10:16

for a map, just use keypath

gdeer8116:10:04

I figured that was the case

gdeer8116:10:30

so for each navigation I'm trying to document intended use and collection types

nathanmarz16:10:51

cool, that's good

nathanmarz16:10:58

would be a good thing to add to the docstrings too

gdeer8116:10:29

ha or even the spec, "spec error: you shouldn't be using this on a set"

michaelwfogleman19:10:25

Does Specter have specs? I didn't think it did

michaelwfogleman19:10:41

I'm pretty new to specs but I'd be willing to help spec Specter if that's of interest

michaelwfogleman20:10:34

Yeah, took another look and pretty sure it doesn't, since it's on 1.8.0 and there's no files included

gdeer8120:10:56

@nathanmarz (let [my-vec ^{:author "Gary"} [1 2 3]] (meta (select ALL-WITH-META my-vec))) returns nil , am I doing something wrong or is this a bug?

michaelwfogleman21:10:03

@gdeer81 @nathanmarz I took a look, it looks like meta is preserved with a transform but not with the select implementation, you can see it in the code too

michaelwfogleman21:10:12

(let [my-num ^{:author "Gary"} [1]] (meta (transform ALL-WITH-META inc my-num)))

michaelwfogleman21:10:23

(defnav ^{:doc "Same as ALL, except maintains metadata on the structure."} ALL-WITH-META [] (select* [this structure next-fn] (n/all-select structure next-fn)) (transform* [this structure next-fn] (let [m (meta structure) res (n/all-transform structure next-fn)] (if (some? res) (with-meta res m) ))))

michaelwfogleman21:10:54

I think I can file a patch 🙂

nathanmarz21:10:04

there's no metadata to maintain on select, since it navigates into the subvalues

nathanmarz21:10:34

that nav purely exists for transforms, especially for codewalker

michaelwfogleman21:10:24

@nathanmarz Ah, looks like this one isn't in the docs either, I'll submit a pr for it

gdeer8122:10:06

I'm going to stick to creating koans for the things documented in the wiki until I'm more attuned with the code

michaelwfogleman22:10:04

Sent in a PR, and a few related to a new issue I opened about undocumented vars: https://github.com/nathanmarz/specter-wiki/issues/17

james23:10:10

Hi everyone, I made a screencast to introduce Specter to newcomers: https://www.youtube.com/watch?v=rh5J4vacG98

michaelwfogleman23:10:37

I've watched a bunch of your older videos, awesome to see one on Specter! Keep them coming! 🙂

Drew Verlee02:10:31

This is awesome