Monus Operator #1343
smithnormform
started this conversation in
Ideas
Monus Operator
#1343
Replies: 1 comment
-
No language extensions are necessary for this; you can just define it, either on the value level, the type level, or both.
You could also use the Unicode symbol for it if you like. |
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
-
It could be nice to have a monus operator in Cryptol. Monus is defined by
a monus b = if a > b then a - b else 0
. According to this Wikipedia article, monus is usually denoted by ∸. You can already implementa monus b
in Cryptol withmax a b - b
, so this would just be syntactic sugar (maybe denoted by*-
).This handy trick can come up when writing recursive functions or really any functions involving degenerate cases.
However, perhaps most of the monus use cases that come to mind could be resolved with some kind of GADT-style pattern matching.
Beta Was this translation helpful? Give feedback.
All reactions