This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-05
Channels
- # admin-announcements (10)
- # beginners (18)
- # boot (29)
- # capetown (2)
- # cider (46)
- # cljs-dev (1)
- # cljsrn (69)
- # clojure (126)
- # clojure-android (9)
- # clojure-gamedev (3)
- # clojure-greece (16)
- # clojure-poland (13)
- # clojure-russia (45)
- # clojure-spec (27)
- # clojure-uk (21)
- # clojurescript (99)
- # cursive (1)
- # datascript (1)
- # datomic (42)
- # functionalprogramming (10)
- # hoplon (47)
- # instaparse (12)
- # jobs (5)
- # jobs-rus (9)
- # keechma (22)
- # lein-figwheel (8)
- # leiningen (5)
- # luminus (1)
- # mount (7)
- # off-topic (1)
- # om (15)
- # onyx (47)
- # other-languages (14)
- # planck (28)
- # proton (8)
- # re-frame (30)
- # reagent (15)
- # remote-jobs (3)
- # slack-help (2)
- # untangled (9)
- # yada (6)
Reading “Out of the Tarpit” (http://shaffner.us/cs/papers/tarpit.pdf), and maybe I’ve just got Spec on my mind, but this looks pretty familiar:
https://www.dropbox.com/s/fjh9fi3r0e4ldt2/Screenshot%202016-07-04%2021.50.02.png?dl=0
The article’s description of "Functional Relational Programming” includes a section on “Essential Logic” that seems to correspond very well with Spec!
I think it's no accident that Clojure+Datomic overlap pretty well with Out of the Tarpit
s/and flows conformed values through the predicates and the s/+ conforms to a vector
Rich has mentioned a split into s/and and s/and-> to have both choices
@alexmiller: Thanks! Yes it could probably be useful sometimes to not have it flow through the predicates but evaluate them separately.
separately, the need to validate this specific case of a regex and vector? is common and one I’ve run into many times in spec’ing macros and there might be some addition specifically for this
Has there been any talk about allowing local registries to use with clojure spec functions rather than only using the global registry? Similar to (make-hierarchy)
and derive
.
I haven't heard such talk :)
I’m trying to use multi-spec
but it doesn’t seem to work with defmethod
’s :default
dispatch, is this a bug or intentional?
I don’t think multi-spec behaves exactly like that. I believe there is no default
to be had.
That’s unfortunate. Is there a better way to handle the validation where a field in the map determines the type and you want to explicitly constrain some types but provide a default base?
Ex: modeling analytics events, the :type
provides the type of event, for :search
events :terms
are required, for :page-view
events :url
is required but for all other events there are no other constraints on the map
hmmm but I just tried (s/def :foo/bad-entity (s/multi-spec entity :does-not-exist))
(gen/sample (s/gen :foo/bad-entity) 1)
and the program goes into an infinite loop
wait! not infinite loop I just get ExceptionInfo Couldn't satisfy such-that predicate after 100 tries.
makes sense it either matches a spec or it does not. I am back to my original argument 😛
I think it’s unexpected behavior if multi-spec
works w/ multimethods but then doesn’t support the default behavior of them
@pdlug: yah I had the same issue I want to dispatch on type
but it has to be based on a key on your map 😞
yeah, my problem is that I want to dispatch on something else than a namespaced key on the map. I want to dispatch on meta
from the map. Not always you want to expose the “type” on the actual entity
ah, I found this open issue: http://dev.clojure.org/jira/browse/CLJ-1935
@pdlug you might also see if s/merge helps you in combining base+specific s/keys