malli

https://github.com/metosin/malli :malli:
ikitommi 2021-05-05T06:48:06.217200Z

great work @ben.sless! need to read the code & think about this a bit. could you check the corresponding features from JSON Schema (https://json-schema.org/understanding-json-schema/reference/object.html#dependencies) so that Malli can be as compliant as it’s reasonable with it. I think your suggestion already a superset of what is in JSON Schema…

ikitommi 2021-05-05T06:49:38.218600Z

meanwhile, a quick poke on the schema inferring / providing: β€’ part1: make it suck less (5x faster on sample dataset): https://github.com/metosin/malli/pull/439 β€’ part2: make inferring first class, most likely 100x faster: https://github.com/metosin/malli/pull/440

ikitommi 2021-05-05T06:52:17.221Z

with part2, all schemas are reponsible for describing how values can/not be described with schemas. This will open up things like inferring types from enums etc, e.g. [:enum "small" "medium" "large"] has a child schema of :string.

ikitommi 2021-05-05T06:53:52.222200Z

the part1 (5x faster) of new provider is now 68 loc, instead of the old 69. The old was kinda bloated anyways πŸ˜‰

ikitommi 2021-05-05T06:56:51.223200Z

➜  malli git:(faster-inferrer-part1) βœ— cloc src --by-file
      15 text files.
      15 unique files.
       0 files ignored.

<http://github.com/AlDanial/cloc|github.com/AlDanial/cloc> v 1.86  T=0.03 s (571.3 files/s, 180498.1 lines/s)
----------------------------------------------------------------------------------------
File                                      blank        comment           code
----------------------------------------------------------------------------------------
src/malli/core.cljc                         146             46           1779
src/malli/impl/regex.cljc                    93             23            508
src/malli/util.cljc                          44             15            350
src/malli/transform.cljc                     64             22            335
src/malli/generator.cljc                     48             13            281
src/malli/error.cljc                         24              6            249
src/malli/clj_kondo.cljc                     21              3            141
src/malli/json_schema.cljc                   23              3            128
src/malli/dot.cljc                            7              3             69
src/malli/provider.cljc                      10              3             68
src/malli/registry.cljc                      15              3             65
src/malli/swagger.cljc                       14              4             51
src/malli/impl/util.cljc                      7              0             24
src/malli/edn.cljc                            3              0             16
src/malli/sci.cljc                            1              0             11
----------------------------------------------------------------------------------------
SUM:                                        520            144           4075
----------------------------------------------------------------------------------------

ikitommi 2021-05-05T06:57:22.223500Z

➜  malli git:(faster-inferrer-part1) cloc test --by-file
      11 text files.
      11 unique files.
       0 files ignored.

<http://github.com/AlDanial/cloc|github.com/AlDanial/cloc> v 1.86  T=0.04 s (264.8 files/s, 133395.9 lines/s)
-----------------------------------------------------------------------------------
File                                            blank        comment           code
-----------------------------------------------------------------------------------
test/malli/core_test.cljc                         330              6           1902
test/malli/util_test.cljc                         115              4            789
test/malli/transform_test.cljc                     93              3            714
test/malli/error_test.cljc                         42              3            439
test/malli/generator_test.cljc                     39              3            266
test/malli/swagger_test.cljc                       11              4            258
test/malli/json_schema_test.cljc                   14              4            236
test/malli/dot_test.cljc                           12              0             73
test/malli/registry_test.cljc                      10              2             61
test/malli/clj_kondo_test.cljc                      8              0             55
test/malli/provider_test.cljc                       4              0             41
-----------------------------------------------------------------------------------
SUM:                                              678             29           4834
-----------------------------------------------------------------------------------

Ben Sless 2021-05-05T07:26:40.224800Z

Regarding part 1, from the profiling I did yesterday it looks like most CPU is based on miu/-fail. I'll profile again with part1 merged to see what conclusions I can infer

1πŸ‘
Ben Sless 2021-05-05T08:14:07.226100Z

disregard the last message I had some repl state

Ben Sless 2021-05-05T08:16:43.226400Z

ok, see ~2x speedup

Ben Sless 2021-05-05T08:18:08.227500Z

-fail still dominates CPU, though. Would you like me to prepare a MR for the exception speedup?

Ben Sless 2021-05-05T18:22:51.229300Z

Question about Malli's design - what's the rationale behind IntoSchemas? Why aren't Schemas and local bindings sufficient?

ikitommi 2021-05-05T21:31:03.229400Z

> For internal elegance, Malli is built using protocols. > It,s much easier to program and reason about the system with protocols than against functions / data. IntoSchema is analogous to a Class and Schena to an Object. There is one shared instance of :map IntoSchema (in a registry) which describes how to create :map Schema instances. And soon how to infer schemas from values. Kinda like adding static methods on classes, except it's all polymorphic.

1πŸ‘