ParseModule
PackageReified.Parse
Primitive parsers for untrusted serialized input.
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. |
| dateOnly | dateOnly text | Parses a date-only value. |
| timeOnly | timeOnly text | Parses a time-only value. |
| 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
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member
Parses an optional input, preserving a present input's parsing failure.
Parameters
| Name | Type | Description |
|---|---|---|
| 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
Parses an optional input, using the supplied fallback only when the input is absent.
Parameters
| Name | Type | Description |
|---|---|---|
| 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
kind:member
kind:member
kind:member
kind:member
kind:member
kind:member