On this pageFunctions
Route
Creates a parser that captures a URL segment as a named integer field.
Fails if the segment is not a valid integer.
<K extends string>(name: K): Biparser<Record<K, number>>Combines multiple parsers, trying each in order until one succeeds.
Returns a Parser (parse-only) since the union of different route
shapes cannot provide a single unified print function.
Creates a parser for a dynamic URL segment with custom parse and print functions.
<A>(
label: string,
parse: (segment: string) => Effect<A, ParseError>,
print: (value: A) => string
): Biparser<A>Parses a URL against a parser, falling back to a not-found route if no parser matches.
<A, B>(
parser: Parser<A>,
notFoundRouteConstructor: {
make: (data: {
path: string
}) => B
}
): (url: {
hash: Option<string>
host: string
pathname: string
port: Option<string>
protocol: string
search: Option<string>
}) => A | BAdds query parameter parsing to a Biparser using an Effect Schema.
Produces a TerminalParser that cannot be extended with slash,
since query parameters must appear at the end of a route definition.
<A, I extends ReadonlyRecord<string, unknown>>(schema: Schema<A, I>): (parser: Biparser<B>) => TerminalParser<B & A>Wraps Schema.TaggedStruct to create a route variant you can call directly as a constructor.
Use r for route types — enabling Home() instead of Home.make().
<Tag extends string>(tag: Tag): CallableTaggedStruct<Tag, {}>
<Tag extends string, Fields extends Fields>(
tag: Tag,
fields: Fields
): CallableTaggedStruct<Tag, Fields>Composes two Biparsers sequentially, combining their parsed values.
Cannot be used after query since query parameters are terminal.
<A extends Record<string, unknown>, B extends Record<string, unknown>>(parserB: Biparser<A>): (parserA: Biparser<B> & {
__terminal: undefined
Cannot use slash after query - query parameters must be terminal: undefined
}) => Biparser<B & A>Creates a parser that captures a URL segment as a named string field.
<K extends string>(name: K): Biparser<Record<K, string>>A bidirectional parser that can both parse URL segments into a value and print a value back to URL segments.
type Biparser = {
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>
print: (value: A, state: PrintState) => Effect.Effect<PrintState, ParseError>
}The result of parsing: a tuple of the parsed value and remaining URL segments.
type ParseResult = [A, ReadonlyArray<string>]A parse-only parser with no print/build capabilities.
Returned by oneOf, which combines multiple parsers whose print
types may differ and therefore cannot be unified into a single Biparser.
type Parser = {
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>
}A parser with a build method that can reconstruct URLs from parsed values.
Created by applying mapTo to a Biparser, binding it to a tagged
type constructor so parsed values carry a discriminant tag and URLs can be
built from tag payloads.
type Router = {
build: (value: A extends {
_tag: string
}
? Omit<A, "_tag">
: never) => string
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>
}A Biparser that has been terminated (e.g. by query) and cannot
be extended with slash.
type TerminalParser = Biparser<A> & {
__terminal: true
}Converts a Biparser into a Router by mapping parsed values to a
tagged type constructor.
The resulting Router can both parse URLs into tagged route values and
build URLs from route payloads.
const mapTo: (appRouteConstructor: {
make: () => T
}) => (parser: Biparser<{}>) => Router<T>