Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the $ operator do?

Tags:

f#

When reading F# code on the net, the dollar operator pops up now and again, for example here: Library patterns Multiple levels of abstraction

However, the Symbol and Operator Reference just says "No more information available".

What does the operator acutally do, and does anybody know where to find any actual documention on it?

like image 289
Ben Schäffner Avatar asked Oct 20 '25 14:10

Ben Schäffner


1 Answers

There is no standard $ operator in the language.

You can, of course define it. The example you have linked uses this definition:

let ($) (DF a) (DF b) = DF (fun ctx -> 
  a(ctx)
  b(ctx) )

where DF is defined via:

type Drawing3D = DF of (Drawing3DContext -> unit)

Further, there are also special restrictions around the use of the $ symbol in more complex operator names, for example the following:

let (<$>) f x = List.map f x

Will result in a compiler error.

error FS0035: This construct is deprecated: '$' is not permitted as a character in operator names and is reserved for future use

like image 158
TheInnerLight Avatar answered Oct 23 '25 07:10

TheInnerLight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!