green-coder / minimallist Goto Github PK
View Code? Open in Web Editor NEWA minimalist data driven data model library, inspired by Clojure Spec and Malli.
License: Eclipse Public License 2.0
A minimalist data driven data model library, inspired by Clojure Spec and Malli.
License: Eclipse Public License 2.0
Show an error message when a model is not found in the context.
It is better than to get nil
and let Minimallist crash somewhere else with no explanation.
Would this allow you to expose more of minimallist to babashka?
The explain
function should indicate the reason why a data would not match a model.
As Minimallist is less and less experimental, used by Vrac on large models, this function really start to become important.
I previously reported this issue in the #minimallist channel on the Clojurians slack.
I'm facing an issue when I'm trying to generate map data with some required keys and some optional keys. Here's what reproduces the issue for me:
(require '[minimallist.helper :as h]) (require '[clojure.test.check.generators :as gen])(-> (h/map) (h/with-optional-entries [:str (-> (h/fn string?) (h/with-test-check-gen gen/string-ascii))]) (h/with-entries [:int (-> (h/fn int?) (h/with-test-check-gen gen/nat))]) mg/gen (gen/sample 20))A few samples show plenty of results that have the :str key without the :int key. What I expect (at least sometimes) to see is the reverse: maps that have the :int key but not the :str key. But I don't:
(-> (h/map) (h/with-optional-entries [:str (-> (h/fn string?) (h/with-test-check-gen gen/string-ascii))]) (h/with-entries [:int (-> (h/fn int?) (h/with-test-check-gen gen/nat))]) mg/gen (gen/sample 2000) (#(filter (fn [m] (and (contains? m :int) (not (contains? m :str)))) %)))This always returns an empty list, regardless of sample size.
In some cases, there is a correlation between what a key and its associated value should be.
An example of that is the format of Clojure's destructuring in bindings.
;; This is a legal destructuring form.
(let [{first-name :first-name
last-name :last-name
:keys [foo bar]
:as foobar} {:first-name "green"
:last-name "coder"
:foo 'foo
:bar 'bar}]
[first-name last-name foo bar foobar])
Changing :map-of
to handle map entries will still allow the users to do whatever was possible with separate models for keys and values, and will additionally permit to handle cases like the one in the example above.
The change to :map-of
is going to be a breaking change.
It should cover:
As suggested by @borkdude, it could be useful to support conformers in Minimallist.
Reference:
https://clojuredocs.org/clojure.spec.alpha/conformer
Use case from @borkdude:
https://gist.github.com/borkdude/6b9c48636b5f9169d26deb13dcfc8ba9
Hello @green-coder how are you? Very nice library this one. Congrats! I am contributing with spec-tools for a while now and I like this subject. Are you planning to work alone in this project or there are plans to onboard new people?
I would like to contribute with some code in spare time if possible. A road map of future enhancements and ideas would be very welcome to understand where are you heading!
Cheers!
This would allow the count-model to be more readable, which will make generating collections of the right size easier.
Proposed format:
{:type :range
:min 1 ; inclusive, optional
:max 3 ; inclusive, optional
:inf -5.0 ; exclusive, optional
:sup 5.0 ; exclusive, optional
}
:min
and :inf
cannot appear at the same time in the node,
:max
and :sup
cannot appear at the same time in the node.
In the following model, the reference to 'bar
is resolved to the wrong model.
(h/let ['foo (h/ref 'bar)
'bar (h/fn int?)]
(h/let ['bar (h/fn string?)]
(h/ref 'foo))
The right way to fix it is to recover the full context of when resolving references.
user=> (require '[minimallist.generator :as mg])
Could not resolve symbol: gen/make-gen [at minimallist/generator.cljc:253:6]
user=>
The main usability problem of Minimallist is that the user does not have a convenient way to bind together some of the data of the model with a user-defined shape of data structure.
We need a good one, the describe
function is too generic.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.