$
is allowed in a custom operator, but if you try to use $$
, <$>
or for instance ~$%
as operator name you will receive the following error:
error FS0035: This construct is deprecated: '$' is not permitted as a character in operator names and is reserved for future use
$
clearly also has the '$' in the name, but works, why?
I.e.:
let inline ( $ ) f y = f y
// using it works just fine:
let test =
let add x = x + 1
add $ 12
I see $
a lot in online examples and apparently as a particular kind of operator. What is this spcial treatment or role for $
(i.e. in Haskell or OCaml) and what should <$>
do if it were allowed (edit)?
Trying to fool the system by creating a function like op_DollarDollar
, doesn't fly, syntax check is done on the call site as well. Though as an example, this trick does work with other (legal) operators:
// works
let inline op_BarQmark f y = f y
let test =
let add x = x + 1
add |? 12
// also works:
let inline op_Dollar f y = f y
let test =
let add x = seq { yield x + 1 }
add $ 12