Is there a way to get a Curried form of the binary operators in SML/NJ?

currying, operators, sml, smlnj

Solution

You could write a helper function that curries a function:

fun curry f x y = f (x, y)

Then you can do something like

val curried_equals = curry (op =)
val l' = if List.exists (curried_equals x) l then l else x::l

Problem

For example, instead of ``` - op =; val it = fn : ''a * ''a -> bool ``` I would rather have ``` - op =; val it = fn : ''a -> ''a -> bool ``` for use in ``` val x = getX() val l = getList() val l' = if List.exists ((op =) x) l then l else x::l ``` Obviously I can do this on my own, for example, ``` val l' = if List.exists (fn y => x = y) l then l else x::l ``` but I want to make sure I'm not missing a more elegant way.

Original source