This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-28
Channels
- # aleph (50)
- # announcements (3)
- # aws (35)
- # beginners (74)
- # boot (25)
- # calva (39)
- # cider (18)
- # clara (2)
- # cljdoc (18)
- # cljs-dev (24)
- # cljsrn (11)
- # clojure (166)
- # clojure-europe (13)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-spec (35)
- # clojure-uk (263)
- # clojurescript (22)
- # clojutre (1)
- # code-reviews (34)
- # cursive (58)
- # data-science (2)
- # datascript (4)
- # datomic (4)
- # duct (6)
- # emacs (7)
- # figwheel-main (9)
- # fulcro (2)
- # graphql (3)
- # hoplon (22)
- # hyperfiddle (2)
- # juxt (5)
- # kaocha (6)
- # leiningen (33)
- # luminus (15)
- # off-topic (1)
- # pedestal (5)
- # reagent (18)
- # reitit (12)
- # shadow-cljs (171)
- # vim (5)
maybe spec is trying to do too much. it’s acting as a specification for: contracts, test value generators, and data coercions
when you make use of chaining predicates to solve your problem, you can express the contract you’d like. but at the cost of support for the other areas
it’s ironic that the argument for spec over any kind of static type system leans significantly on expressiveness. but with that expressiveness (i.e., arbitrary predicates) comes tradeoffs that make difficult to accomplish some of the other goals of spec
@lilactown I think your :user/super-cool-program
(or something as specific as such fields combination) should be just predicate with a custom generator.
@favila what is the downside (and is there any?) of always having conformed datomic's :db/id tagged, like [:lookup-ref [:user/name "foo"]] or [:perm-int 12345]. Where do you actually need to constantly check against e.g. not-a-temp-id, so you'd be forced to come up with funky qualifying s/and, etc.?
ofc, I'd love to always get conformed {:db/id 1234} out of queries/pulls. But is it a high price?
that means you'd need to conform first, and have function working with conformed map, right?
Typing a map intended for a tx is harder because you’re typing a particular instance of a dsl
yeah, does this mean entire app's specs will know about datomic (app uses datomic and the :user/friends is a :db.type/ref)? or is there another way?
you don't have to spec every attribute
In other map contexts or parts of the app the same attr means something different (eg it’s meant for a tx later, or it can be anything d/entid can resolve)
Alex, true. I need to think through what I will not get if I omit :db.type/ref
s from spec registry, e.g. generative testing or validation -wise
Is there any reason the following two definitions would not be equivalent? I'm having some problems with the one using partial.
@josip.gracin Works for me:
user => (defprotocol Foo
(foo [this]))
Foo
user=> (extend-type java.lang.Long Foo (foo [this] this))
nil
user=> (s/valid? :n/k 1)
false
user=> (satisfies? Foo 1)
true
user=> (s/valid? :n/k 1)
false
user=> (s/def :n/k (partial satisfies? Foo))
:n/k
user=> (s/valid? :n/k 1)
true
it could be that after you change the protocol, you have to re-define the spec. to be sure, just reload your program entirely
thanks! I just needed a sanity check before I go further into debugging. I have a situation where those two behave differently.
@josip.gracin there are some nuances between the 2 in spec2: read ~10-20msgs starting from https://clojurians.slack.com/archives/C1B1BB2Q3/p1551208861176100
@misha thanks! I'm using spec1 for this.