This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-13
Channels
- # beginners (71)
- # boot (61)
- # clara (49)
- # cljs-dev (9)
- # cljsjs (2)
- # cljsrn (5)
- # clojure (55)
- # clojure-android (1)
- # clojure-italy (4)
- # clojure-spec (39)
- # clojure-uk (56)
- # clojurescript (69)
- # cursive (5)
- # data-science (1)
- # defnpodcast (6)
- # devcards (1)
- # duct (12)
- # figwheel (3)
- # fulcro (18)
- # leiningen (35)
- # lumo (19)
- # midje (1)
- # off-topic (22)
- # om (3)
- # onyx (23)
- # portkey (3)
- # re-frame (20)
- # reagent (23)
- # ring-swagger (6)
- # shadow-cljs (119)
- # specter (7)
- # unrepl (25)
what I mean: you can compute the firsts set of a regular expression and you can also compute its derivative towards a prefix
(defn firsts
([re] (firsts re (s/form re)))
([re form]
(case (::s/op re)
::s/pcat (if-let [[p & ps] (:ps re)]
(into (firsts p (first (:forms re)))
(when (s/valid? p nil)
(firsts (-> re (assoc :ps (vec ps))
(update :ks (comp vec next))
(update :forms (comp vec next)))
’???)))
#{})
::s/alt (into #{} (mapcat firsts (:ps re) (:forms re)))
::s/accept #{}
#{form})))
=> (firsts (s/cat :name symbol? :meta map?))
#{clojure.core/symbol?}
=> (firsts (s/cat :name (s/? symbol?) :meta map?))
#{clojure.core/symbol? clojure.core/map?}
what is this sorcery
@pesterhazy given a regular expression you can know what are the valid inputs for the first transition (“firsts set”)
given a regular expression and a prefix you can compute the remaining regular expression after having consumed prefix
for example with https://github.com/clojure/core.specs.alpha/blob/master/src/main/clojure/clojure/core/specs/alpha.clj#L57
you can have the following interactions (pipe being the caret)
(if-l|
(if-let [|] ; autompletion automatically creates the vector because it’s the only valid input, a hint may say that a binding is epxected
...
@pesterhazy anything against the use of spec in unravel?
Might slow lumo down significantly
spec is precompiled in Lumo
AOTed to JS
I’ve done it https://github.com/Unrepl/unravel/blob/sideloader/src/unravel/core.cljs#L20-L34