This topic provides a table that shows how to specify the type of a literal in F#.
The following table shows the literal types in F#. Characters that represent digits in hexadecimal notation are not case-sensitive; characters that identify the type are case-sensitive.
Suffix or prefix
signed 8-bit integer
unsigned 8-bit natural number
signed 16-bit integer
unsigned 16-bit natural number
signed 32-bit integer
l or none
unsigned 32-bit natural number
u or ul
native pointer as an unsigned natural number
signed 64-bit integer
unsigned 64-bit natural number
32-bit floating point number
F or f
4.14F or 4.14f
64-bit floating point number
4.14 or 2.3E+32 or 2.3e+32
integer not limited to 64-bit representation
fractional number represented as a fixed point or rational number
M or m
0.7833M or 0.7833m
"""<book title="Paradise Lost">"""
"string1" + "string2"
See also Strings (F#).
String or byte
Unicode strings can contain explicit encodings that you can specify by using \u followed by a 16-bit hexadecimal code or UTF-32 encodings that you can specify by using \U followed by a 32-bit hexadecimal code that represents a Unicode surrogate pair.
As of F# 3.1, you can use the + sign to combine string literals. You can also use the bitwise or (|||) operator to combine enum flags. For example, the following code is legal in F# 3.1:
[<Literal>] let literal1 = "a" + "b" [<Literal>] let fileLocation = __SOURCE_DIRECTORY__ + "/" + __SOURCE_FILE__ [<Literal>] let literal2 = 1 ||| 64 [<Literal>] let literal3 = System.IO.FileAccess.Read ||| System.IO.FileAccess.Write
The use of other bitwise operators isn't allowed.
Values that are intended to be constants can be marked with the Literal attribute. This attribute has the effect of causing a value to be compiled as a constant.
In pattern matching expressions, identifiers that begin with lowercase characters are always treated as variables to be bound, rather than as literals, so you should generally use initial capitals when you define literals.