Skip to content

Base

module Base
AssemblyFable.UrlParser

Declared inside

Helpers
ParseFailure
ParserError
ParserState
Query
UrlContext
UrlParser

Functions and values

apply<'a> (UrlParser<'a>) (context: UrlContext) : Result<ParserState<'a>,ParseFailure>
custom<'A, 'Output> (typeName: string) (tryParse: string -> 'A option) (innerParser: UrlParser<('A -> 'Output)>) : UrlParser<'Output>

Consume the next path segment and parse it with a custom conversion function.

This function will fail if:

  • There are no remaining segments to consume.
  • tryParse returns None for the segment value.
Parameter
typeNameName reported in the error message when conversion fails, e.g. "Guid"
tryParseFunction attempting to convert the segment string into 'A
innerParserParser to apply

Returns. The converted value of the consumed segment

fragment<'Output> (innerParser: UrlParser<(string option -> 'Output)>) : UrlParser<'Output>

Read the URL fragment (the part after #).

Parameter
innerParserParser to apply

Returns. Some string if a fragment is present

None if there is no fragment

int<'Output> (innerParser: UrlParser<(int -> 'Output)>) : UrlParser<'Output>

Consume the next path segment and parse it as an integer.

This function will fail if:

  • There are no remaining segments to consume.
  • The next segment cannot be parsed as a valid integer.
Parameter
innerParserParser to apply

Returns. The integer value of the consumed segment

makeError<'a> (depth: int) (error: ParserError) : Result<'a,ParseFailure>
map<'A, 'B> (f: 'A -> 'B) (parser: UrlParser<'A>) : UrlParser<'B>

Transform the output of a finished parser.

Parameter
fFunction to transform the output
parserParser to transform
parse<'Output> (parsers: UrlParser<'Output> list) (context: UrlContext) : Result<'Output,ParserError>
pathToSegments (path: string) : string list
pathToUrlContext (path: string) : UrlContext
segment<'Output> (expected: string) (innerParser: UrlParser<'Output>) : UrlParser<'Output>

Match a literal path segment.

This function will fail if:

  • There are no remaining segments to consume.
  • The next segment does not match expected.
Parameter
expectedThe literal segment value to match
innerParserParser to apply
string<'Output> (innerParser: UrlParser<(string -> 'Output)>) : UrlParser<'Output>

Consume the next path segment as a string.

This function will fail if:

  • There are no remaining segments to consume.
Parameter
innerParserParser to apply

Returns. The string value of the consumed segment

succeed<'Output> (output: 'Output) : UrlParser<'Output>