Fork me on GitHub
#malli
<
2020-09-11
>
ikitommi09:09:54

@tekacs not 100% sure about your use case, what about using transformers?

tekacs23:09:57

I was hoping rather to do something more like gen/fmap but for malli types. The hope being to be able to first run a transform on a value before validating it using an existing/builtin validator. I can do this today using simple-schema or similar, but passing errors along is just tricky.

ikitommi15:09:24

does the new -simple-schema solve this?

ikitommi09:09:37

I recently tested the end-to-end performance of JSON and realized we could plug malli into the jsonista pipeline: define a malli schema, create a jsonista functional-decoder out of it which picks just the defined keys from the JSON stream and runs (already optimized) value transformation for it. As there are no intermediate conversions, it should be MUCH faster.

ikitommi10:09:01

• old-style json: stream --json-decode--> edn --schema-decode--> domain-data --json-encode--> string --ring-adapter--> bytes • malli+jsonista: stream --json-and-schema-decode--> domain-data --json-and-schema-encode--> bytes

borkdude10:09:25

@ikitommi That's exactly an issue that I posted a couple of years ago in the compojure-api channel :) Awesome that this will now be supported via malli!

borkdude10:09:21

This is typically what you do in typed languages: write (de)serialization code which results in very efficient JSON processing. But in Clojure we typically just parse the entire blob

borkdude10:09:30

If you have a working example of this, I'd be very interested

borkdude10:09:45

since jsonista is also based on jackson-core I might be able to switch/add from cheshire to jsonista without adding very much binary size. if we then also add malli and reitit and http-kit server ... in babashka I mean. small web-apps :)

ikitommi14:09:02

that would be great! Would like to get vertx working with clj + graalvm at some point. After that, one could write a code that can run really fast with jvm, with low resources with graalvm and with bb for scripting.

ikitommi14:09:46

reitit+jsonista+porsas+pohjavirta is still one of the fastest jvm stacks in techempower db-query tests. It's a silly benchmark, but, still.

ikitommi15:09:09

don't have an example of the json+malli, just know it's possible. Will do.

tekacs23:09:57

I was hoping rather to do something more like gen/fmap but for malli types. The hope being to be able to first run a transform on a value before validating it using an existing/builtin validator. I can do this today using simple-schema or similar, but passing errors along is just tricky.