Add maps used by postwalk-replace or functions that return a transformed pattern here, and they will be applied to each rule pattern with [[do-pattern-replace]] before the rule is compiled.
Add maps used by postwalk-replace or functions that return a transformed pattern here, and they will be applied to each rule pattern with [[do-pattern-replace]] before the rule is compiled.
(apply-predicator {:keys [abbr predicate metadata]} pattern)(apply-replacements pattern replacements)(make-abbr-predicator abbr predicate)(make-abbr-predicator metadata abbr predicate)Create a function that when applied to a pattern, will add the given
predicate to any short-form var that has the given abbr as the main
component of its name, or if it has a prefix, that matches the prefix.
Actually just captures the data to build it. The function itself can be built on demand and this way it's more inspectable.
Example:
(make-abbr-predicator 'sym symbol?)
As applied to various patterns:
?sym => (? sym ~symbol?)
?sym*0 => (? sym*0 ~symbol?)
??sym => (?? sym ~symbol?)
??->sym+ => (??-> sym+ ~symbol?)
?<-$!sym:name => (?<-$! sym:name ~symbol?)
;; abbr must match, and matcher must be short-form:
?x => ?x
(? sym) => (? sym)
If metadata is provided, it will be attached to the matcher name, and the
matcher will be marked with a $ mode character.
?sym => (?$ ~(with-meta 'sym metadata) ~symbol)
Create a function that when applied to a pattern, will add the given
predicate to any short-form var that has the given `abbr` as the main
component of its name, or if it has a prefix, that matches the prefix.
Actually just captures the data to build it. The function itself can be built
on demand and this way it's more inspectable.
Example:
(make-abbr-predicator 'sym symbol?)
As applied to various patterns:
?sym => (? sym ~symbol?)
?sym*0 => (? sym*0 ~symbol?)
??sym => (?? sym ~symbol?)
??->sym+ => (??-> sym+ ~symbol?)
?<-$!sym:name => (?<-$! sym:name ~symbol?)
;; abbr must match, and matcher must be short-form:
?x => ?x
(? sym) => (? sym)
If `metadata` is provided, it will be attached to the matcher name, and the
matcher will be marked with a `$` mode character.
?sym => (?$ ~(with-meta 'sym metadata) ~symbol)(match-abbr abbr)(var-abbr prefix n)(with-predicates pred-map & forms)For all rules defined within this block, matchers in rules with the given abbreviations or names will automatically have the given predicate attached to them.
(with-predicates {'i int?}
(rule '[?i ?i1 ??i*]
;; i, i1, and i* are guaranteed to be integers.
(apply + i i1 i*)))
For all rules defined within this block, matchers in rules with the given abbreviations or names will
automatically have the given predicate attached to them.
(with-predicates {'i int?}
(rule '[?i ?i1 ??i*]
;; i, i1, and i* are guaranteed to be integers.
(apply + i i1 i*)))
(with-predicates* pred-map body-fn)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |