Malli is a new Clojure/Script library for elegant data-driven data modelling. It is born from the real world needs of dynamic, distributed and multi-tenant systems: Schemas to describe the data should be first-class data. They should drive the runtime value transformations, web forms, rules and processes. Configuration should be explicit – no magic, macros or mutability. We should be able to infer, create and modify the models at runtime, persist and load them back from database and share over the wire, for both Clojure and ClojureScript. Like JSON Schema, but for EDN & Clojure/Script.
In this talk, I’ll walk through the core concepts, features and the lessons learned on creating Malli. I’ll also demonstrate some cool new things we can do with literal data schemas and compare it to prior art, including clojure.spec, plumatic schema and JSON Schema.
6. • Data-oriented - represent entities and their relationships as data.
• Data-driven - create DSLs in data structures and write interpreters for
them
Clojure <3 Data
https:!"clojureverse.org/t/clojure-a-pragmatic-data-driven-language/4565/5Eric Normand
17. Expectations
We are building dynamic multi-tenant systems where data-
models should be data too: they should drive the runtime value
transformations, forms and processes.We should be able to edit
the models at runtime, persist them and load them back from
database and over the wire, for both Clojure and ClojureScript.
Think of JSON Schema, but for EDN and Clojure/Script.
18. If you have expectations (of others) that aren't
being met, those expectations are your own
responsibility.You are responsible for your own
needs. If you want things, make them.
- Rich Hickey
https:!"gist.github.com/richhickey/1563cddea1002958f96e7ba9519972d9
20. The Idea
• Schemas as data (hiccup, reagent, internal.*, reitit)
• Take the best parts of Plumatic Schema, clojure.spec & JSON Schema
• Programming with Schemas, first class meta-data
• Focus on Developer Experience
• Small core, extendable
• Create a Prototype, experiment, have fun
46. • reitit-malli coercion module, since 0.4.0
• Orders of magnitude faster coercion than with reitit-spec
• Small example application: https://github.com/metosin/reitit/tree/
master/examples/ring-malli-swagger
• A new module & configuration system?
reitit + malli
48. • Have generated forms in four decades, just one more time ;)
• Good companion for FSMs and rule engines, rapid prototyping
• https://www.youtube.com/watch?v=IekPZpfbdaI
• https://github.com/domino-clj + malli
Generating UIs
Dmitri Carmen Nikola
Schema '( UI %& Schema UI-Schema '( UI
49. • Inspired by expound, backed by metosin/virhe
Errors for Developers
Ben Brinkerhoff
50. • malli-powered code checking: https://github.com/teknql/aave
• Add support schematized defn and fn
• Emit clj-kondo type annotations
• Schemas for Schemas AST
• Test utilities
MoreTooling
Ryan Schukler
Michiel Borkent
51.
52. • Pre-alpha, still experimenting, but core is 90% code complete
• Was public announcement by the community long time ago
• Many active contributors and some users too
• Big thanks to all people and libraries for source of innovation
• Goal to get official release out in a month or two
• Learned a lot, has been fun to develop
Current Status
53. • Understand and manage your expectations
• Clojure is awesome tool for building data-driven systems
• Malli is a fresh new schema library for Clojure/Script, try it out
• If you’re interested in type and schema systems, consider contributing
• https://github.com/metosin/malli
• #malli on slack
Takeaways