Skip to main content
Version: 0.62.0

Int, Float, Bool Modules

Int​

Int.tryParse : string -> int option​

let maybeN = Int.tryParse "42"

Int.toString : int -> string​

let text = Int.toString 42

Float​

Float.tryParse : string -> float option​

let maybePi = Float.tryParse "3.14"

Float.toString : float -> string​

let text = Float.toString 3.14

Bool​

Bool.tryParse : string -> bool option​

let maybeFlag = Bool.tryParse "true"

Bool.toString : bool -> string​

let text = Bool.toString true

Parsing pattern​

Use parsing helpers with options:

let port =
Int.tryParse "8080"
|> Option.defaultValue 80