Ben Schäffner
Ben Schäffner

Reputation: 360

What does the $ operator do?

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?

Upvotes: 4

Views: 285

Answers (1)

TheInnerLight
TheInnerLight

Reputation: 12184

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

Upvotes: 5

Related Questions