Fork me on GitHub

I have a spec:

(s/def ::statement (s/cat ::header ::header
                          ::delimiter ::delimiter
                          ::txs-header ::txs-header
                          ::txs ::txs))
-- is it how it is supposed to look like, or am I missing some shorthand?


::header, ::delimiter etc are declared using s/cat themselves, so I suppose s/tuple can't be used here.


Maybe there is a simpler way to spec this data format? The input is a CSV file parsed into a vector of vectors. Header is a number of lines, more-or-less fixed, but some are optional and may be omitted. Delimiter is a single fixed line. Txs headers is another set of more-or-less fixed lines, and txs is the rest of the document.

Alex Miller (Clojure team)13:05:45

s/tuple might be better

Alex Miller (Clojure team)13:05:48

For vector of fixed position fields


Too bad they are mostly, but not completely, fixed. Banks are, well, banks.


I would turn the vec of vecs into a vec of maps, then spec with s/keys


Parsing individual lines is not so bad — they can be handled by s/tuple. Parsing the sequence of lines is worse.


I'll leave it with s/cat for now.