Syntax error with ( let_ )

I’m getting a syntax error with this letop definition:

let ( let_ ) o f = Option.iter f o
             ^ Syntax error

However the equivalent desugared form works:

let ( let_ ) = fun o f -> Option.iter f o

Any ideas why?

_ is not a valid “letop” suffix, but let_ is a valid identifier, so let ( let_ ) = ... is interpreted as binding a (unary) tuple pattern: you could do let let_ o f = ... but this will be a usual function binding, not a “letop” definition.

Cheers,
Nicolas

2 Likes