I loved this syntax in OCaml
match myCompare xy with |Greater-> |Less-> |Equal->
However, this requires 2 things, a custom type and the function myCompare, which returns my custom type.
Would it be all the same to do this without following the above steps?
The pervasives module seems to have a “comparison” that returns 0 if it is equal, pos int when greater, and neg int less. Can they be matched? Conceptually in a similar way (which does not compile):
match myCompare xy with | (>0) -> | (0) -> | (<0) ->
I know that I can just use if statements, but template comparison is more elegant for me. Is there a simple (if not standard) way to do this?
source share