This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-25
Channels
- # bangalore-clj (5)
- # beginners (225)
- # boot (36)
- # cider (1)
- # clara (2)
- # cljsjs (1)
- # clojure (76)
- # clojure-belgium (1)
- # clojure-conj (1)
- # clojure-india (4)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (22)
- # clojure-spec (35)
- # clojure-uk (52)
- # clojurescript (67)
- # community-development (17)
- # core-logic (2)
- # cursive (2)
- # datascript (28)
- # datomic (44)
- # emacs (1)
- # funcool (3)
- # hoplon (14)
- # lein-figwheel (2)
- # leiningen (2)
- # luminus (3)
- # midje (3)
- # mount (2)
- # nyc (2)
- # om (54)
- # om-next (1)
- # onyx (30)
- # re-frame (57)
- # reagent (19)
- # ring-swagger (23)
- # slack-help (10)
- # spacemacs (2)
- # specter (1)
- # vim (23)
hi all. I’ve been looking at extracting the minimum and maximum values from specs created with s/int-in
and s/double-in
...
and then created seperate functions to pull the mins and maxs from the conformed maps that I create with these.
but the code is 50 lines long? https://gist.github.com/triss/1128bcfeb1a71c7e09ffd9cf10be0370
So those will s/form back to their original form in the future (I know they are a mess now). That plus a spec on those forms makes this just a conform away.
@yonatanel plan is just to test (and built utilities) out things that we are using with Schema. For Schema we have the schema-tools library (https://github.com/metosin/schema-tools) having modified versions of the core functions for maps. In top there are special walkers, transformers and matchers. Using those both at design & runtime. At runtime, have used schemas for example for frontend form validation, and the forms/schemas can change based on the user input. With Spec, there could be either more functions/macros to manipulate the Specs (like s/merge
) or a new MapSpec record which could be used like a regular map. Maybe someone has tried the map-approach already? What use cases / requirements do you have?
(s/def ::timestamp (s/with-gen (partial instance? DateTime)
(fn [] (gen/fmap #(DateTime. %)
(gen/large-integer*
{:min (c/to-long
(t/minus (t/now)
(t/days 365)))})))))
in 1.9, you can extend the (new) Inst protocol to DateTime - if you do so, you should be able to use s/inst-in
but what you have should work
ExceptionInfo Call to #‘bar/foo did not conform to spec:
val: (#function[clojure.core/identity]) fails at: [:args] predicate: ifn?
:clojure.spec/args (#function[clojure.core/identity])
:clojure.spec/failure :instrument
:clojure.spec.test/caller {:file "form-init100394334971998293.clj", :line 917, :var-scope bar/eval55924}
clojure.core/ex-info (core.clj:4617)
(s/fdef foo
:args (s/cat :function (s/fspec :args (s/cat :arguments number?)
:ret any?))
:ret 3)
(defn foo [f] (f 3))
http://dev.clojure.org/jira/browse/CLJ-2013 - Are there plans to fix this for 1.9? It would greatly increase error message quality. Is work on it welcome?