-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure all examples work without sci unless mentioned otherwise #733
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would not require sci:
;; portable :gen/fmap
(mg/generate
[:and {:gen/fmap (partial str "kikka_")} string?]
{:seed 10, :size 10})
;; => "kikka_WT3K0yax2"
if you think so, we could add both examples for clarity. anyway 👍
Good point! I adjusted it so that there are now both examples, first the "simple one" and then the portable one. ;; :gen/fmap
(mg/generate
[:and {:gen/fmap (partial str "kikka_")} string?]
{:seed 10, :size 10})
;; => "kikka_WT3K0yax2"
;; portable :gen/fmap (requires `org.babashka/sci` dependency to work)
(mg/generate
[:and {:gen/fmap '(partial str "kikka_")} string?]
{:seed 10, :size 10})
;; => "kikka_nWT3K0ya7"
I hope it's clear enough that the first one will only work on the particular runtime and the quoted one can be serialized. 🤔 (I also hope that I got it right 😉) |
ee7d063
to
0c09695
Compare
Hmm I think there's similar gotcha in
(m/validate
[:multi {:dispatch 'first}
[:sized [:tuple keyword? [:map [:size int?]]]]
[:human [:tuple keyword? [:map [:name string?] [:address [:map [:country keyword?]]]]]]]
[:human {:name "seppo", :address {:country :sweden}}])
; true I guess also here unquoted |
Actually, @ikitommi we should probably clarify in the README what are the limitations to functions in general
If you think this is a good idea I could make a separate issue + PR about it. |
Yes, all examples besides a specific sci-part could be without sci. Any function works in all places. Quoting is just a trick to get 'em serialized. Feel free to tune the README however it's better. |
:gen/fmap
example requires sci
I went through all the examples in I also lifted commonly used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so good.
Closes #723