ParseModule

PackageReified.Parse
Primitive parsers for untrusted serialized input.

Summary

NameSignatureSynopsis
Operations
intint textParses a 32-bit integer.
longlong textParses a 64-bit integer.
decimaldecimal textParses a decimal number.
floatfloat textParses a double-precision floating point number.
boolbool textParses a boolean.
guidguid textParses a GUID.
dateTimedateTime textParses a date and time value.
dateTimeOffsetdateTimeOffset textParses a date and time value with offset.
enumenum textParses an enum value by name or numeric text.
optionaloptional parser inputParses an optional input, preserving a present input's parsing failure.
optionalOroptionalOr fallback parser inputParses an optional input, using the supplied fallback only when the input is absent.
intOptionintOption textParses an optional integer.
boolOptionboolOption textParses an optional Boolean.
decimalOptiondecimalOption textParses an optional decimal.
guidOptionguidOption textParses an optional GUID.
intOrDefaultintOrDefault fallback textParses an optional integer, using the supplied fallback only when the input is absent.
boolOrDefaultboolOrDefault fallback textParses an optional Boolean, using the supplied fallback only when the input is absent.
decimalOrDefaultdecimalOrDefault fallback textParses an optional decimal, using the supplied fallback only when the input is absent.

Operations

kind:member

int

int text
Member
Parses a 32-bit integer.

Parameters

NameTypeDescription
textstring

Returns

Result<int, ParseError>
kind:member

long

long text
Member
Parses a 64-bit integer.

Parameters

NameTypeDescription
textstring

Returns

Result<int64, ParseError>
kind:member

decimal

decimal text
Member
Parses a decimal number.

Parameters

NameTypeDescription
textstring

Returns

Result<decimal, ParseError>
kind:member

float

float text
Member
Parses a double-precision floating point number.

Parameters

NameTypeDescription
textstring

Returns

Result<float, ParseError>
kind:member

bool

bool text
Member
Parses a boolean.

Parameters

NameTypeDescription
textstring

Returns

Result<bool, ParseError>
kind:member

guid

guid text
Member
Parses a GUID.

Parameters

NameTypeDescription
textstring

Returns

Result<Guid, ParseError>
kind:member

dateTime

dateTime text
Member
Parses a date and time value.

Parameters

NameTypeDescription
textstring

Returns

Result<DateTime, ParseError>
kind:member

dateTimeOffset

dateTimeOffset text
Member
Parses a date and time value with offset.

Parameters

NameTypeDescription
textstring

Returns

Result<DateTimeOffset, ParseError>
kind:member

enum

enum text
Member
Parses an enum value by name or numeric text.

Parameters

NameTypeDescription
textstring

Returns

Result<'enum, ParseError>
kind:member

optional

optional parser input
Member
Parses an optional input, preserving a present input's parsing failure.

Parameters

NameTypeDescription
parser'raw -> Result<'value, 'error>
input'raw option

Returns

Result<'value option, 'error>

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"))
kind:member

optionalOr

optionalOr fallback parser input
Member
Parses an optional input, using the supplied fallback only when the input is absent.

Parameters

NameTypeDescription
fallback'value
parser'raw -> Result<'value, 'error>
input'raw option

Returns

Result<'value, 'error>

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"))
kind:member

intOption

intOption text
Member
Parses an optional integer. Absence returns Ok None; malformed present text returns its parsing error.

Parameters

NameTypeDescription
textstring option

Returns

Result<int option, ParseError>

Verification Examples

Parse.intOption (Some "42") = Ok (Some 42)
kind:member

boolOption

boolOption text
Member
Parses an optional Boolean. Absence returns Ok None; malformed present text returns its parsing error.

Parameters

NameTypeDescription
textstring option

Returns

Result<bool option, ParseError>

Verification Examples

Parse.boolOption (Some "true") = Ok (Some true)
kind:member

decimalOption

decimalOption text
Member
Parses an optional decimal. Absence returns Ok None; malformed present text returns its parsing error.

Parameters

NameTypeDescription
textstring option

Returns

Result<decimal option, ParseError>

Verification Examples

Parse.decimalOption (Some "12.5") = Ok (Some 12.5M)
kind:member

guidOption

guidOption text
Member
Parses an optional GUID. Absence returns Ok None; malformed present text returns its parsing error.

Parameters

NameTypeDescription
textstring option

Returns

Result<Guid option, ParseError>

Verification Examples

Parse.guidOption None = Ok None
kind:member

intOrDefault

intOrDefault fallback text
Member
Parses an optional integer, using the supplied fallback only when the input is absent.

Parameters

NameTypeDescription
fallbackint
textstring option

Returns

Result<int, ParseError>

Verification Examples

Parse.intOrDefault 80 None = Ok 80
kind:member

boolOrDefault

boolOrDefault fallback text
Member
Parses an optional Boolean, using the supplied fallback only when the input is absent.

Parameters

NameTypeDescription
fallbackbool
textstring option

Returns

Result<bool, ParseError>

Verification Examples

Parse.boolOrDefault false None = Ok false
kind:member

decimalOrDefault

decimalOrDefault fallback text
Member
Parses an optional decimal, using the supplied fallback only when the input is absent.

Parameters

NameTypeDescription
fallbackdecimal
textstring option

Returns

Result<decimal, ParseError>

Verification Examples

Parse.decimalOrDefault 5.5M None = Ok 5.5M