Ahh, thanks for the heads up!
This is the minimal failing example I could come up with extracted from a
larger spec. In the original spec both ::a and ::b contain several other
keys with with simple predicates like string?, pos-int? etc. FWIW, adding
some additional keys like this to ::a and ::
FYI, s/fdef takes a qualified symbol, not a keyword, and it should refer to
a function of the same qualified name. But you could do this instead to
address that:
(s/def ::a-fn
(s/fspec
:args (s/cat :arg ::a)
:ret ::a))
How could this even generate anything? That is, what would you exp
I just ran in to a similar issue:
-
(require '[clojure.spec :as s])
(s/def ::a (s/keys :req [::b]))
(s/fdef ::a-fn
:args (s/cat :arg ::a)
:ret ::a)
(s/def ::b (s/keys :req [::a-fn]))
;; All of these fail even with s/*recursion-limit* bound to 1.
(s/exercise ::
Hi,
I am struggling with recursive Spec declarations, more in particular how
two Spec definitions can refer to each other. In the example below, I use a
"forward" declaration, but that does not seem very elegant. Am I missing
something?
The more fundamental question, however, is how to imple
Le jeudi 9 juin 2016 15:30:08 UTC+2, Christophe Grand a écrit :
>
> Hi Frédéric,
>
>
> First question : is there a better way to define a set of mutually
> recursive specs ?
>
> No it's ok but you can remove (s/def ::odd nil).
>
>
Oh yes you're right
f ::even (s/or :zero ::zero ; 0 is even
> :even (s/tuple ::succ ::odd))) ; n+1 is even if
> n is odd
> (s/def ::odd (s/tuple ::succ ::even)) ; n+1 is odd if n is even
> ;; ==
>
> First question : is there a better way to define a set of m
/tuple ::succ ::odd))) ; n+1 is even if
n is odd
(s/def ::odd (s/tuple ::succ ::even)) ; n+1 is odd if n is even
;; ==
First question : is there a better way to define a set of mutually
recursive specs ?
This seems to work anyways :
;; ===
(s/conform ::even :zero