Fork me on GitHub

Hi folks, I’ve been looking for an excuse to use Meander for a while and I think I have a good use case now. One question I’m struggling with: for boring reasons, I’d like to define my input and output patterns in advance, separate from when I actually invoke Meander. But I have some transformation functions I want to use in the output pattern that rely on runtime context (in my case, a DB connection): an example input pattern:

{:id ?epic-id
        :input {:team ?team-id}}
an example output pattern:
{:id (resolve-as-type db :entity-type/epic ?epic-id)
           :input {:team_id (resolve-as-type db :entity-type/team ?team-id)}})      
My question is: is there some way to pass in parameters to an invocation of m/match (or any of the other top-level Meander macros) that are then available in the patterns? (e.g., the equivalent to the :in clause of a Datomic query).


and if not, what kind of patterns do people have for threading runtime context down into function calls in an output pattern?


You can use unquote ~ in most pattern places, and in the substitution of m/rewrite

👍 1

thanks! Is there an example of this somewhere in the docs? I’m not sure I understand what the semantics of ~ would be here.