Fork me on GitHub
#malli
<
2023-02-22
>
Noah Bogart14:02:55

Y'all know about https://github.com/borkdude/speculative? It was an attempt at adding clojure.spec specs for nearly all of the clojure.core functions, both as a means of documentation and a way to check input-output when doing development. It stalled out as clojure.spec is not performant enough. now that I've added instrumenting vars in other namespaces, I wonder if we could do a malli version of speculative, see if the performance is any better/if it would help uncover spaces where malli could improve

borkdude14:02:00

speculative still has its use, e.g. in https://borkdude.github.io/re-find.web/ I think even with a malli speculative, instrumenting core would just be way too slow and probably not worth it

Noah Bogart14:02:31

oh cool! I didn't realize you were using it for re-find, I thought you were using something like grasp.

borkdude14:02:53

a good test case would be advent of code puzzles. at one point I had a solution which took 15 minutes with instrumentation and 50ms without or so

2
borkdude14:02:20

(exact number I don't remember but it was something absurd like that)

Noah Bogart14:02:28

yeah, it's debatable if it would be worth it, but malli is pretty dang fast comparatively: 40ns vs 450ns for simple schemas. 10x speed increase is sharp

borkdude14:02:56

10x won't really solve that problem imo

borkdude14:02:16

the problem is that some core functions will become 1000x slower

borkdude14:02:48

but exact benchmarks must be done to revalidate that, it's been a while

Joel19:02:02

How do validate that I have a valid malli (vector) schema? Or, what is the schema of schemas? eg.

[:map
 [:attribute :keyword]
 [:schema [:and :vector :schema]]
.core/child-error {:type :schema, :properties nil, :children nil, :min 1, :max 1}

frank19:02:27

there's a malli.core/schema? that looks promising

Joel20:02:57

Looks like that checks to see if it’s an instance of a schema, which would force me to invoke (schema) on the data. I’ve been on the fence on how proactive I should be about doing that. I do see there is (form) which does get the data back… I was expecting that there was a schema schema somewhere though.

dvingo01:02:46

I've just wrapped (malli.core/schema <args>) in a try catch - catch branch returns false to determine if a valid schema is passed in

2