What's meaning of NumericLiteralN in F#? -


in following dsl example (http://fssnip.net/bb), code presented:

module numericliteraln =     let fromzero() = ""     let fromone() = "n"     let fromint32 x = string.replicate x "n"  // calls fromone(): let x11 = 1n // val x1 : string = "n" 

i don't understand code let x11 = 1n @ all. know there class microsoft.fsharp.math.numericliteraln in fsharp.powerpack. codes overwrite methods of microsoft.fsharp.math.numericliteraln class?

quoting tomas' blog (http://tomasp.net/blog/fsharp-custom-numeric.aspx)

to define literal, need write module special name. inside module, implement several functions used automatically in f# compiler whenever literal used:

module numericliteralz =     let fromzero () = z5 0 3:      let fromone  () = z5 1  4:      let fromint32 = integerz5.create(a%5) 5:     let fromint64 = integerz5.create(int(a%5l)) 

the name of module consists of special name numericliteral followed symbol z we’ll use writing our literals. means we’ll able write literals such 0z, 1z , 42z. module may provide several functions enable several sizes of literals.

effectively name numericliteral"x" special , compiler automatically generates code make things work.

in example, "n" resturned value of 1 using fromone().

your code has definition positive int32 values - although fail on -1n.


Comments