Fork me on GitHub
#malli
<
2020-10-28
>
borkdude10:10:55

@ikitommi I think I would have a real good use of sequence schemas. Spec is painful to work for command line usage with due to macros, malli is a pleasure because it's data and also compatible with Graal. Context: https://gist.github.com/borkdude/a391146ad81a06c28fb97ccdc1f64d44

👍 6
2
jeroenvandijk10:10:42

I was thinking about this too. To find duplicated or similar code etc

Joel20:03:15

Does Grasp support malli-style --- yet? @U04V15CAJ

borkdude20:03:19

@UH13Y2FSA Do you have an idea what that would look like? we could maybe work on that, but right now it doesn't do anything with malli

Joel20:03:58

No, not really. I looked at Grasp, and decided it’s along the lines of what I need, but then since I know Malli and not Spec, have to say I wasn’t eager to figure out Spec as well. 😞

borkdude20:03:57

if you can give me your query, I will try to translate it to spec

borkdude20:03:05

and then it should be not too hard to make changes

Joel20:03:55

Changes from time to time, but an example would be to find cases of (get <symbol> <string> any) Looking specifically for when not-found is used

Joel20:03:04

We have a deftype that implements IFn… so can also be (<symbol> <string> any) The not-found parameter being that <any> of course.

borkdude20:03:25

ok, that would be something like:

(g/cat 'get symbol? string? any?)

2
Joel20:03:22

Thanks, ill check into grasp, we do this type of thing periodically and regex usually falls short.

Joel22:03:12

Something as simple as this should work, no? grasp -p src/test/clojure -e "string?"

borkdude22:03:59

it's been a while since I used the binary to be honest. I usually write a script like this: https://github.com/borkdude/grasp/blob/master/examples/case_symbols.clj

borkdude22:03:44

I'll try it now...

borkdude22:03:58

yes, that works, but there's one caveat, try symbol? instead of string?

borkdude22:03:03

since a string can't carry metadata

borkdude22:03:10

and thus has no location to point to

borkdude22:03:47

this section applies to that problem: https://github.com/borkdude/grasp#finding-keywords replace the word keyword for string there

Joel22:03:29

weird, neither work for me. eg. grasp -p src/test/clojure -e "symbol?" I’m double-checking path and all, recursively there are .clj files, it does error if i give the -e garbage. I guess I’ll try using library instead.

borkdude22:03:03

This is what I see locally:

$ grasp -p src -e "symbol?"
file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:1:2
(ns native.test

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:1:5
(ns native.test

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:2:14
  (:require [org.httpkit.client :as client]

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:2:37
  (:require [org.httpkit.client :as client]

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:3:14
            [org.httpkit.server :as server]

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:3:37
            [org.httpkit.server :as server]

file:/Users/borkdude/dev/http-kit/test-native/src/native/test.clj:4:14
            [clojure.test :as t])

borkdude22:03:09

(and a lot more output)

Joel22:03:37

I wonder if it has to do with being on aarch64 OSX.

borkdude22:03:54

I'm also on aarch64 macos, but I have rosetta installed

Joel22:03:41

Same. so weird. ill just go from source/lib.

borkdude23:03:03

maybe it's your shell

borkdude23:03:10

that does stuff with the question mark?

borkdude23:03:32

dunno. try 'symbol?'

borkdude23:03:38

single quotes?

Joel23:03:52

no. wondering if i was redirecting output somehow… opened up another shell. no output.

Joel23:03:10

Getting error messages if i mess up the expression… `Exception in thread “main” java.lang.Exception: Unable to resolve spec: symbol?’ at grasp.impl.spec$reg_resolve_BANG_.invokeStatic(spec.clj:74)`

borkdude23:03:00

ok, just go with the jvm lib

2
borkdude10:10:33

Imagine that the user can specify a schema on the command line to search for code patterns.

👍 6
2