package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module contains primitive parsers. Not useful on their own, but when combined with the parsers in the Parser module they become useful.

type 'a t

A 'a Value_parser.t will parse string -> 'a and unparse 'a -> string

val int : int t
val string : string t
val float : float t
val bool : bool t
val stringable : (module Core.Stringable with type t = 'a) -> 'a t
val sexpable : (module Core.Sexpable with type t = 'a) -> 'a t
val binable_via_base64 : (module Core.Bin_prot.Binable.S with type t = 'a) -> 'a t
val base64_encoded : 'a t -> 'a t

base64_encoded will decode the URL component before parsing, and encode the URL component after unparsing.

val project : 'a t -> parse_exn:('a -> 'b) -> unparse:('b -> 'a) -> 'b t

Turns a parser of type 'a to a parser of type 'b.

Properties:

  • If the parse_exn function fails, so does the entire parser.
val fallback : 'a t -> fallback:'a -> 'a t

fallback parser value parses into value every time that parser fails.

val name : string -> 'a t -> 'a t

Displays a different name when shown in url. e.g. instead of:

project (fallback string)

appearing as "/?q=<project<fallback<string>>>"

you could do:

name "username" (project (fallback string))

and it would appear as "/?q=<username>"

OCaml

Innovation. Community. Security.