Fork me on GitHub
#specter
<
2017-12-13
>
mbjarland13:12:10

Hi @nathanmarz, now this might be a noob question, but how would I go about getting rid of the following warning when building my lein project (which has specter in the depenendency graph):

WARNING: any? already refers to: #'clojure.core/any? in namespace: com.rpl.specter.impl, being replaced by: #'com.rpl.specter.impl/any?

mbjarland13:12:18

clojure 1.9.0

nathanmarz13:12:09

@mbjarland ah i'll need to release a new version that renames those functions

mbjarland13:12:25

I'm using midje for testing which in turn pulls in marick/suchwow which in turn pulls in specter 0.13.0...ah ok

mbjarland13:12:04

do you want the dependency graph or any other details from my side?

nathanmarz13:12:30

no, that's fine

nathanmarz13:12:01

you'll need to open an issue with midje to update its dependencies

nathanmarz13:12:12

looks like it's really outdated

mbjarland13:12:48

would be glad to, though it might be worth waiting until you do your update before creating the ticket

nathanmarz13:12:26

just checked, that function no longer exists in specter codebase so there are no warnings with latest version

mbjarland13:12:56

ha, ok I'll create a ticket now then

nathanmarz13:12:25

oh apparently I knew about and fixed this a long time ago: https://github.com/nathanmarz/specter/blob/master/CHANGES.md#0131

mbjarland13:12:25

unfortunate fact

mbjarland13:12:50

suchwow (which is the immediate dep of midje) has not changed since the 6.0.0 version which midje is using

mbjarland13:12:19

this brings to mind Rich's talk about dependency hell...

mbjarland14:12:25

so I would have to file a ticket with suchwow and once they update, file a ticket with midje?

nathanmarz14:12:31

@mbjarland yea, it's an annoying problem with the jvm

nathanmarz14:12:45

but yes, that would be the approach to use

nathanmarz14:12:05

it would probably be a lot faster for you to just fork the projects yourself in the meantime

mbjarland14:12:31

I created a ticket and referenced the pr, now we wait

abdullahibra15:12:53

@nathanmarz (select [ALL (selected? :p1 ALL :name (pred= "wow"))] data) => this expression check for "wow" word, what if i want to check multiple different words

abdullahibra15:12:21

for example: all contains "wow" or contains "good"

abdullahibra15:12:54

(or (pred= "wow") (pred= "good")) ?

nathanmarz15:12:43

@abdullahibra replace (pred= "wow") with #{"wow" "good"}

abdullahibra15:12:47

what if i want to use custom function rather than match string? maybe regexp matcher for example

nathanmarz15:12:14

@abdullahibra you can insert any clojure function into a path

nathanmarz15:12:54

if it returns nil or false, it ceases navigation there

nathanmarz15:12:30

regexes are also natively supported, they navigate to every substring match

abdullahibra15:12:35

#{"wow" (fn [s] (re-find #"[g|G]ood" s))} this is right?

nathanmarz15:12:52

so (selected? #"aaa") would act as a filter

nathanmarz15:12:12

no, sets are interpreted just like a function

nathanmarz15:12:20

(since sets are functions in clojure)

nathanmarz15:12:22

you would want either (fn [s] (or (= "wow" %) (re-find ...))) or (selected? (multi-path (pred= "wow") #"[g|G]ood"))

nathanmarz15:12:48

multi-path within a selected? functions like an or

abdullahibra15:12:10

that's really cool

abdullahibra15:12:14

thanks man for this

abdullahibra16:12:33

for this data: [{:s1 "cool" :p1 [{:name "hello" :sen "good"} {:name "world", :sen "nothing"}]}, {:s2 "cool2" :p1 [{:name "wow", :sen "fine"} {:name "world",, :sen "none"}]}]

abdullahibra16:12:24

@nathanmarz helped me to extract all hash maps which match "wow" or regexp, and for multiple words i would like to do this: (selected? (apply multi-path [#"regexp1" #"regexp2"])) and what if i want to match two cases in the same time, so i want to catch the :name which has regexp and :sen which has also regexp

nathanmarz16:12:37

don't do (apply multi-path ...)

nathanmarz16:12:52

inefficient and unecessary

nathanmarz16:12:05

to match multiple cases just put multiple conditions consecutive in the path

abdullahibra16:12:07

what if i have big list of regexp?

abdullahibra16:12:13

what i would like to get any hash map which match any from regexp-list1 and regexp-list2 from two different paths

abdullahibra16:12:30

one path from :name and other from :sen

nathanmarz16:12:41

you can do the (apply multi-path some-list) but there will be ways to optimize that if you have perf problems

nathanmarz16:12:27

(selected? (multi-path :key1 :key2) (multi-path (pred= "wow") #"some-regex"))

nathanmarz16:12:52

that would check that either :key1 or :key2 is either "wow" or matches that regex

abdullahibra16:12:33

but if i would like to match :name is "wow" AND :sen is "good"

abdullahibra16:12:01

so i don't get match for :name "wow" and :sen "nothing"

nathanmarz16:12:12

[#(= "wow" (:name %)) #(= "good" (:sen %))]

abdullahibra16:12:36

without multipath ?

nathanmarz16:12:35

multi-path navigates to multiple paths

nathanmarz16:12:05

for "and", it's just multiple navigators in a row, for "or" it's (selected? (multi-path ...))

abdullahibra16:12:19

ah okay got this

nathanmarz16:12:15

these are just how those concepts emerge from navigation