Re: Recursive specs & forward declarations

2017-01-02 Thread John Schmidt
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 ::

Re: Recursive specs & forward declarations

2017-01-01 Thread Alex Miller
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

Re: Recursive specs & forward declarations

2017-01-01 Thread John Schmidt
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 ::

Recursive specs & forward declarations

2016-07-01 Thread Maarten Truyens
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

Re: recursive specs

2016-06-09 Thread Frederic Peschanski
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

Re: recursive specs

2016-06-09 Thread Christophe Grand
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

recursive specs

2016-06-09 Thread Frederic Peschanski
/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