Fork me on GitHub
#clojure-australia
<
2021-05-03
>
Hugh Powell00:05:01

Morning folks 👋

lsenjov22:05:55

Morning all 👋 Spent a couple hours yesterday retrofitting schema’s defn macro to work with malli instead

👋 2
anonimitoraf08:05:30

Mind sharing how? Im curious because Im starting to play around with malli myself. Also, what are your thoughts on spec 2?

lsenjov23:05:20

Grabbed the schema macros and modified them to use malli instead

lsenjov23:05:24

That's honestly it 😂

lsenjov23:05:58

Was actually fairly painless, just a bit of thinking

lsenjov23:05:09

As for spec2, I've only glanced at it but I'm still not sold

lsenjov23:05:49

Putting things in a registry and needing a separate fdef, both make it harder to read things

anonimitoraf09:05:22

Oh right. How did you go about instrumenting with malli? (Assuming you do)

lsenjov21:05:03

Not specifically instrumenting. So spec has its instrument for replacing a function with a version with the fdef applied. Schema's version is to declare it on the defn itself with some optional symbol :- type syntax, then switch it on with a global var

lsenjov22:05:04

There's also a switch for not allowing compilation at all, so it just adds the raw defn without any checking (basically elide asserts)

lsenjov22:05:28

Plus it constructs the equivalent of fdef while you're at it

anonimitoraf00:05:09

Reading schema's docs (Ive not used it before) :- seems to be just for type hints, is that right?

lsenjov23:05:23

Basically yeah. Although it also attaches pre/post maps validating those types when checking is on