The above issue should be fixed now, thanks @borkdude. Not sure about the data reader but I might add a macro version.
Hey cool. What about removing test.check from the main dependencies? I would suggest letting users bring in test.check themselves (like for clojure.spec, etc)
yes, that seems like a good idea. I'll do the same with spec / spec-alpha2 / malli in the future, as the idea is to provide integrations with those.
the way CLJS solves this is to let users require test.check explicitly themselves and then check in the namespaces that use it if it's already required, if not, emit a warning. I like that solution better than the dynaload thing that JVM Clojure does which seems more complex.
Note that usage as data reader already works:
$ clj -Sdeps '{:deps {regal {:git/url "<https://github.com/lambdaisland/regal>" :sha "468195aa81fcbd73c2c8e566c57411f359950a23"}}}'
Clojure 1.10.1
user=> (require '[lambdaisland.regal :as re] '[clojure.edn :as edn])
nil
user=> (edn/read-string {:readers {'regal/regex re/regex}} "#regal/regex [:range \\A \\Z]")
#"[A-Z]"
Maybe nice to add to the docs.Documented it here: https://github.com/lambdaisland/regal/pull/2
I would rather not encourage using a data reader for this. I'm becoming wary of data reader overuse. A regal expression is already plain data and so can go into EDN fine. If you want to precompile you can use a macro or cache the result. The presence of a data reader implies the presence of a printer, which there isn't.
ok. about the other issue you just closed: I don't think that's fixed at all test.check is still brought in as a dependency https://github.com/lambdaisland/regal/blob/468195aa81fcbd73c2c8e566c57411f359950a23/deps.edn#L3 and lambdaisland.regex still requires the generators namespace, so it's not optional at all
aaaanyway...
right the top level namespace does provide a shorthand for generators/gen and generators/sample... you're right this needs a little more smarts
and I should remember to git push
...
I'd say just take a look at how malli does it, it's the same as my suggestion
So taking out the top level require
i.e. the generators namespace should probably not be loaded by the "core" namespace
Yeah... definitely the easiest approach
small price to pay I'd say for users who do want to use the generators: they are going to require the test.check + lambdaisland.regal/generators namespace
then I might as well get rid of the top level, it'll just be a
(defn regex [r]
(pattern/regex r))
yes
I'm sure you are also aware of https://github.com/gfredericks/test.chuck#string-from-regex?
I used that in speculative to test specs for re-find, etc.
I was not, thanks for the pointer!
might look at how they do the regex parsing, as it would be great to be able to go regex -> regal in the future
might be nice to link to prior / alternative work in this area (there are some others which I can't think of of the top of my head right now)
afk now
I was pointed at the Common Lisp equivalent, which would be interesting to study
The top level no longer depends on generators, instead l.r.pattern
has been promoted/renamed to the top level lambdaisland.regal
terrific