meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
2019-11-08T20:23:04.203700Z

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)))

2019-11-08T20:27:36.204Z

; 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

jimmy 2019-11-08T20:28:46.204200Z

(m/match {:state {:limit 100}
          :transaction {:amount 30}}
  (m/and {:state {:limit ?limit}
          :transaction {:amount ?amount}}
          (m/guard (< ?limit ?amount)))
  (- ?limit ?amount))

jimmy 2019-11-08T20:29:16.204900Z

(I didn't run this) Did you mean to have (- ?limit ?amount) as the output?

jimmy 2019-11-08T20:29:30.205400Z

If so you had a misplaced parenthesis that was causing the error above.

jimmy 2019-11-08T20:29:47.205600Z

@dev964

2019-11-08T20:30:57.206600Z

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

jimmy 2019-11-08T20:32:39.207500Z

limit is not less than amount. So it fails.

2019-11-08T20:33:04.207800Z

ahh, great - thanks!

jimmy 2019-11-08T20:33:25.208200Z

No problem. We could definitely make the no rhs error better.

jimmy 2019-11-08T20:34:08.208900Z

The non-exhaustive pattern match could also be better, but no rhs should be an easy one to fix.