Skip to content

matcher for gensyms #29

Closed
Closed
@thumbnail

Description

@thumbnail

Context

macroexpand= is great; but unifies any symbol it recognizes as a gensym. providing a matcher-combinators matcher for gensyms allows for more specific matches

Task

  1. add a GensymMatcher + wrapper fns
  2. add readme examples

Additional resources

Blocked by #28, at least for the opt-in requirement of m-c.

In an internal project we use:

(defrecord GensymMatcher [expected]
 matcher-combinators.core/Matcher
 (match [_this actual]
   (let [value (symbol (string/replace actual #"(.?+)(\d)*" "$1"))]
     (if (= expected value)
       {:matcher-combinators.result/type   :match
        :matcher-combinators.result/value  value
        :matcher-combinators.result/weight 0}
       {:matcher-combinators.result/type   :mismatch
        :matcher-combinators.result/value  (model/->Mismatch expected value)
        :matcher-combinators.result/weight 1}))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions