This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-27
Channels
- # announcements (10)
- # bangalore-clj (1)
- # beginners (130)
- # calva (8)
- # cider (66)
- # circleci (2)
- # clojure (197)
- # clojure-europe (2)
- # clojure-italy (8)
- # clojure-nl (5)
- # clojure-spec (14)
- # clojure-uk (35)
- # clojurescript (46)
- # code-reviews (5)
- # cursive (4)
- # datomic (88)
- # duct (1)
- # emacs (2)
- # figwheel-main (15)
- # fulcro (20)
- # graalvm (1)
- # graphql (3)
- # jackdaw (2)
- # leiningen (2)
- # off-topic (64)
- # pathom (53)
- # re-frame (52)
- # reagent (12)
- # reitit (43)
- # rewrite-clj (1)
- # shadow-cljs (38)
- # spacemacs (3)
- # sql (17)
- # tools-deps (6)
- # vim (30)
Hi, I’ve read the spec guide and couldn’t really come up with the correct way to do the following; Apologies if i had missed something. I am looking to define a spec for a ::paragraph that consists of “::words” , “::space(s)” , and “less often” ::punctuation. It (of course) does not need to be grammatically correct. It seems like i need something like s/cat however i want the results to be not a vec but a larger string (that consists of smaller “spec” strings...“). I’m interested in having a spec for ::paragraph as well as a generator to play with a natural language processing app i’m working on. Any tips appreciated,
I managed to do something like that by using conformer
to tokenize the string first. E.g.:
(s/and string?
(s/conformer #(str/split % #",") #(str/join "," %))
(s/cat ...))
But it won’t be as fast as a real parser. I think you’re probably asking for more out of spec than it is designed to provide
Is there a version (in some library, etc) of s/keys
that allows me do manipulate the spec definition before proceeding?
My current pattern for that is:
(eval `(spec/keys :req ~(conj dependencies ::foo-options)))
...Generally it works fine, but now my needs also include clojurescript, so I can't use eval
I don't think there is an easy pattern for it in spec 1. CLJ-2112 has a sketch of specs for specs which lets you conform, modify then unform, but it's pretty cumbersome due to the structure of s/keys.
spec 2 has several ways to do this and a new symbolic map form in work in particular