Hi everyone, is there a way to have a guard predicate acting on values extracted from match
(m/match {:state {:limit 100}
:transaction {:amount 30}}
(m/and {:state {:limit ?limit}
:transaction {:amount ?amount}}
(m/guard (< ?limit ?amount))
(- ?limit ?amount)))
; jvm/err | Syntax error macroexpanding meander.match.epsilon/match at (src/meander/meander.clj:4:1).
; jvm/err | () - failed: Insufficient input at: [:clauses :rhs] spec: :meander.match.epsilon/expr
(m/match {:state {:limit 100}
:transaction {:amount 30}}
(m/and {:state {:limit ?limit}
:transaction {:amount ?amount}}
(m/guard (< ?limit ?amount)))
(- ?limit ?amount))
(I didn't run this) Did you mean to have (- ?limit ?amount)
as the output?
If so you had a misplaced parenthesis that was causing the error above.
yes, the parenthesis was misplaced! But it still returns an error...
; jvm/err | Syntax error (ExceptionInfo) compiling at (src/meander/meander.clj:4:1).
; jvm/err | non exhaustive pattern match
limit is not less than amount. So it fails.
ahh, great - thanks!
No problem. We could definitely make the no rhs error better.
The non-exhaustive pattern match could also be better, but no rhs should be an easy one to fix.