ParseModule
Parse
Reified.Parse converts serialized text into primitive typed values. Unlike Int32.TryParse, it returns a value
identifying which of three failures occurred: MissingValue, InvalidFormat, or OutOfRange. Every parser takes
string and returns Result<'value, ParseError>.
| Parser | Returns | Accepts |
|---|---|---|
Parse.int |
int |
Optionally signed digits, invariant culture. |
Parse.long |
int64 |
As int, with the wider range. |
Parse.decimal |
decimal |
Digits with an optional sign, decimal point, and thousands separators, invariant culture. |
Parse.float |
float |
Digits with an optional leading sign, decimal point, thousands separators, and exponent notation, invariant culture. |
Parse.bool |
bool |
"true" or "false", any casing. Not "1", "yes", or "on". |
Parse.guid |
System.Guid |
Any format Guid.TryParse accepts, including braced and hyphenless. |
Parse.dateTime |
System.DateTime |
Invariant-culture date and time text, such as "2026-03-04T09:30:00". |
Parse.dateTimeOffset |
System.DateTimeOffset |
As dateTime, with an offset such as "+10:00". |
Parse.dateOnly |
System.DateOnly |
Invariant-culture date text. .NET 8+ only. |
Parse.timeOnly |
System.TimeOnly |
Invariant-culture time text. .NET 8+ only. |
Parse.enum<'enum> |
'enum |
A case name, case-insensitive, or its numeric text. |
Numeric parsers use invariant culture: the same text parses the same way on every machine, and the decimal point is
., not ,. They also ignore leading and trailing whitespace; whitespace-only input is still MissingValue.
Only Parse.int, Parse.long, and Parse.decimal can produce OutOfRange; every other parser reports MissingValue
or InvalidFormat. Parse.float never reports OutOfRange: input beyond float's range parses as infinity or
-infinity, and input too close to zero parses as 0.0.
See Parsing for the failure cases and the optional/defaulting helpers.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Operations | ||
| int | int text | Parses a 32-bit integer. |
| long | long text | Parses a 64-bit integer. |
| decimal | decimal text | Parses a decimal number. |
| float | float text | Parses a double-precision floating point number. |
| bool | bool text | Parses a boolean. |
| guid | guid text | Parses a GUID. |
| dateTime | dateTime text | Parses a date and time value. |
| dateTimeOffset | dateTimeOffset text | Parses a date and time value with offset. |
| enum | enum text | Parses an enum value by name or numeric text. |
| optional | optional parser input | Parses an optional input, preserving a present input's parsing failure. |
| optionalOr | optionalOr fallback parser input | Parses an optional input, using the supplied fallback only when the input is absent. |
| intOption | intOption text | Parses an optional integer. |
| boolOption | boolOption text | Parses an optional Boolean. |
| decimalOption | decimalOption text | Parses an optional decimal. |
| guidOption | guidOption text | Parses an optional GUID. |
| intOrDefault | intOrDefault fallback text | Parses an optional integer, using the supplied fallback only when the input is absent. |
| boolOrDefault | boolOrDefault fallback text | Parses an optional Boolean, using the supplied fallback only when the input is absent. |
| decimalOrDefault | decimalOrDefault fallback text | Parses an optional decimal, using the supplied fallback only when the input is absent. |
Operations
Parameters
| Name | Type | Description |
|---|---|---|
| parser | 'raw -> Result<'value, 'error> | |
| input | 'raw option |
Returns
Verification Examples
Parse.optional Parse.int None = Ok None
Parse.optional Parse.int (Some "42") = Ok (Some 42)
Parse.optional Parse.int (Some "bad") = Error (ParseError.InvalidFormat ("int", "bad"))Parameters
| Name | Type | Description |
|---|---|---|
| fallback | 'value | |
| parser | 'raw -> Result<'value, 'error> | |
| input | 'raw option |
Returns
Verification Examples
Parse.optionalOr 80 Parse.int None = Ok 80
Parse.optionalOr 80 Parse.int (Some "443") = Ok 443
Parse.optionalOr 80 Parse.int (Some "bad") = Error (ParseError.InvalidFormat ("int", "bad"))