lambdaisland

plexus 2020-02-12T09:20:23.006100Z

The above issue should be fixed now, thanks @borkdude. Not sure about the data reader but I might add a macro version.

borkdude 2020-02-12T09:26:29.006700Z

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)

plexus 2020-02-12T09:31:30.007600Z

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.

borkdude 2020-02-12T10:04:42.008900Z

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.

borkdude 2020-02-12T10:11:50.009300Z

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=&gt; (require '[lambdaisland.regal :as re] '[clojure.edn :as edn])
nil
user=&gt; (edn/read-string {:readers {'regal/regex re/regex}} "#regal/regex [:range \\A \\Z]")
#"[A-Z]"
Maybe nice to add to the docs.

borkdude 2020-02-12T10:20:49.009500Z

Documented it here: https://github.com/lambdaisland/regal/pull/2

plexus 2020-02-12T11:02:35.011600Z

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.

borkdude 2020-02-12T11:04:51.012700Z

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

borkdude 2020-02-12T11:08:35.013100Z

aaaanyway...

plexus 2020-02-12T11:09:44.014Z

right the top level namespace does provide a shorthand for generators/gen and generators/sample... you're right this needs a little more smarts

plexus 2020-02-12T11:10:18.014300Z

and I should remember to git push...

borkdude 2020-02-12T11:10:46.014700Z

I'd say just take a look at how malli does it, it's the same as my suggestion

plexus 2020-02-12T11:11:01.015Z

So taking out the top level require

borkdude 2020-02-12T11:11:10.015400Z

i.e. the generators namespace should probably not be loaded by the "core" namespace

plexus 2020-02-12T11:11:18.015700Z

Yeah... definitely the easiest approach

borkdude 2020-02-12T11:11:59.016300Z

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

plexus 2020-02-12T11:13:18.016900Z

then I might as well get rid of the top level, it'll just be a

(defn regex [r]
  (pattern/regex r))

borkdude 2020-02-12T11:14:11.017100Z

yes

borkdude 2020-02-12T11:14:29.017300Z

I'm sure you are also aware of https://github.com/gfredericks/test.chuck#string-from-regex?

borkdude 2020-02-12T11:14:48.018Z

I used that in speculative to test specs for re-find, etc.

plexus 2020-02-12T11:15:09.018200Z

I was not, thanks for the pointer!

plexus 2020-02-12T11:15:35.018700Z

might look at how they do the regex parsing, as it would be great to be able to go regex -> regal in the future

borkdude 2020-02-12T11:17:02.019700Z

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)

borkdude 2020-02-12T11:17:11.019900Z

afk now

plexus 2020-02-12T11:17:33.020300Z

I was pointed at the Common Lisp equivalent, which would be interesting to study

plexus 2020-02-12T15:26:16.022200Z

The top level no longer depends on generators, instead l.r.pattern has been promoted/renamed to the top level lambdaisland.regal

borkdude 2020-02-12T21:21:44.022400Z

terrific