ParseModule

PackageReified.Parse
Primitive parsers for untrusted serialized input.

Summary

NameSignatureSynopsis
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.
dateOnlydateOnly textParses a date-only value.
timeOnlytimeOnly textParses a time-only value.
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.

int

int text
Member
Parses a 32-bit integer.

Parameters

NameTypeDescription
textstring

Returns

Result<int, ParseError>

long

long text
Member
Parses a 64-bit integer.

Parameters

NameTypeDescription
textstring

Returns

Result<int64, ParseError>

decimal

decimal text
Member
Parses a decimal number.

Parameters

NameTypeDescription
textstring

Returns

Result<decimal, ParseError>

float

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

Parameters

NameTypeDescription
textstring

Returns

Result<float, ParseError>

bool

bool text
Member
Parses a boolean.

Parameters

NameTypeDescription
textstring

Returns

Result<bool, ParseError>

guid

guid text
Member
Parses a GUID.

Parameters

NameTypeDescription
textstring

Returns

Result<Guid, ParseError>

dateTime

dateTime text
Member
Parses a date and time value.

Parameters

NameTypeDescription
textstring

Returns

Result<DateTime, ParseError>

dateTimeOffset

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

Parameters

NameTypeDescription
textstring

Returns

Result<DateTimeOffset, ParseError>

dateOnly

dateOnly text
Member
Parses a date-only value.

Parameters

NameTypeDescription
textstring

Returns

Result<DateOnly, ParseError>

timeOnly

timeOnly text
Member
Parses a time-only value.

Parameters

NameTypeDescription
textstring

Returns

Result<TimeOnly, ParseError>

enum

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

Parameters

NameTypeDescription
textstring

Returns

Result<'enum, ParseError>

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"))

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"))

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)

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)

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)

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

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

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

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