Replies: 1 comment
-
This isn't possible in the current version because you need an input value to create a match expression and they are evaluated eagerly. What you could do however is to return a function that takes your input: const createMatcher = (...thingsToGenerateBranches) => {
return function matcher(input) {
let expr = match(input)
// ... generate branches based on createMatcher's input
return expr.otherwise(...)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First, thanks for this awesome library, really fun to think of solving problems using this pattern and improves discussion with non-technical people.
I have a pattern where I load a bunch of mappings from a file and then want to match lines from a CSV to those mappings. Here's a ChatGPT translated version of what I'm doing (it's written originally in ClojureScript) (where
mappings
is a cache of the mappings from a CSV.I'm not too concerned about performance since this is a batch job handler but I was hoping to build up the
matcher
once and then re-use it with different values. Is this possible?Beta Was this translation helpful? Give feedback.
All reactions