Two simple F # questions

There are two F # snippets that I would like to understand, but donโ€™t know what to do with Google. Firstly:

let ``1+2`` () = .... 

I assume this simply means "turn expression into identifier"? But what is this function if I want to refer to it?

Secondly, what does the ^ symbol mean when it occurs in a type? I found several references to this, but the explanation always just says "type this", and not "it is different from the type without 1 ^ 1 in this ...". For instance:

 let inline blah xy = x+y;; val inline blah : ^a -> ^b -> ^c when ( ^a or ^b) : (static member ( + ) : ^a * ^b -> ^c) 

Thank you very much in advance.

+4
source share
2 answers

The backquote syntax is just a way to โ€œquoteโ€ arbitrary characters into identifiers, I'm not sure if it has a name. It is commonly used, for example,

 let ``This Identifier Contains Spaces`` = 42 

or

 foo.``member``(42) // 'member' is an F# keyword, but maybe it was the name of some // method from C# code you're using, so here a way to call it 

A carat indicates a parameter of a statically permitted type:

http://msdn.microsoft.com/en-us/library/dd548046.aspx

Used for special overload / community.

+1
source

All Articles