clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
2020-01-21T01:14:27.041Z

In spec2, is it possible to use s/conform on a vector parsed via a sequence matcher like vcat and then getting back a vector via s/unform?

2020-01-21T01:16:01.041600Z

From the documentation, it does not look like it would work.

alexmiller 2020-01-21T02:55:31.042100Z

Yes, it works now

alexmiller 2020-01-21T02:56:13.042500Z

With s/catv

alexmiller 2020-01-21T02:59:45.043100Z

What documentation are you referring to?

2020-01-21T13:05:06.045700Z

@alexmiller I had this impression after reading those 2 places: • https://github.com/clojure/spec-alpha2/wiki/Differences-from-spec.alpha#scat which hints that vcat uses s/and- , • and https://github.com/clojure/spec-alpha2/wiki/Differences-from-spec.alpha#nonflowing-sand--new which does not say that s/unform validates other preds in a s/and-.

2020-01-21T13:09:38.048700Z

The example about s/vcat may potentially confuse people w.r.t. s/catv .

alexmiller 2020-01-21T13:24:34.049200Z

Thx, I’ll update that

Filipe Silva 2020-01-21T15:32:20.050Z

heya

Filipe Silva 2020-01-21T15:32:34.050400Z

are there any breaking changes one should be aware of between 0.1x and 0.2.x for spec?

Filipe Silva 2020-01-21T15:33:09.051200Z

I'm updating a project's cljs 1.10.520 to `1.10.597` , and my production build now fails when loading something spec related

Filipe Silva 2020-01-21T15:33:55.051900Z

| TypeError: Cannot read property 'prototype' of ...
                                                V
$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha62946$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$256$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
  return $APP.$cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $APP.$cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $APP.$cljs$spec$alpha$op_describe$$(this.$re$));
});

Filipe Silva 2020-01-21T15:34:13.052200Z

doesn't seem to affect the normal build though

G 2020-01-21T16:49:23.056400Z

Have folks ever used spec to define a transformation between namespaced, clojure maps to another format? My use case is creating maps in clojure but transforming them to JSON, and I don't want for there to be coupling between my clojure key names (ie. namespaced keywords) and my JSON maps (which may even contain keys that aren't representable as clojure keywords)

G 2020-01-21T16:53:30.057800Z

I was hoping to have the resulting key name as part of the spec so as to keep all of the relevant information about that attribute in one place, but perhaps this is best done outside of spec?

ghadi 2020-01-21T16:55:10.058700Z

you can store a lookup from qualifiedkey -> key in a sibling database, doesn't have to be in the spec registry

👍 1
cjsauer 2020-01-21T21:17:19.061Z

@lewis you can have a look at this little lib I wrote a while ago for a similar use case https://github.com/cjsauer/disqualified

cjsauer 2020-01-21T21:18:05.061700Z

Might not be exactly what you’re needing but could serve as a possible reference

cjsauer 2020-01-21T21:18:20.062100Z

It’s less than 50 lines of code

G 2020-01-21T21:23:01.062400Z

it's not exactly what I'm looking for right now (for instance, my un-namespace keys have conflicting names, although the full paths are distinct), but this is definitely useful! I've had to implement something very similar for another project, so will keep this in mind in the future 🙂

👍 1