package vdom

  1. Overview
  2. Docs

Module Vdom.DecoderSource

Sourcetype arg_value =
  1. | StringArg of string
  2. | BoolArg of bool
  3. | FloatArg of float
  4. | IntArg of int
Sourcetype _ t =
  1. | Field : string * 'msg t -> 'msg t
  2. | Method : string * arg_value list * 'msg t -> 'msg t
  3. | Bind : ('a -> 'msg t) * 'a t -> 'msg t
  4. | Const : 'msg -> 'msg t
  5. | Factor : ('a -> 'msg t) -> ('a -> ('msg, string) Result.t) t
  6. | String : string t
  7. | Int : int t
  8. | Float : float t
  9. | Bool : bool t
  10. | Object : js_object t
  11. | List : 'a t -> 'a list t
  12. | Fail : string -> 'msg t
  13. | Try : 'a t -> 'a option t
    (*

    The type of JavaScript object "structural" parsers. It allows to access the fields of JS objects and cast them to OCaml values.

    *)
Sourceval field : string -> 'a t -> 'a t

field s d accesses field s and applies decoder d to it. Deeper sub-fields can also be accessed by giving the full list of field names separated by dots.

Sourceval method_ : string -> arg_value list -> 'a t -> 'a t

method_ s l q calls method s with arguments l and applies d to the result.

Sourceval app : ('a -> 'b) t -> 'a t -> 'b t

Monadic applicative operation

Sourceval bind : ('a -> 'b t) -> 'a t -> 'b t

Monadic binding operation

Sourceval const : 'a -> 'a t

const x is a decoder that always returns x on any JS object

Sourceval return : 'a -> 'a t

return x is a decoder that always returns x on any JS object

Sourceval factor : ('a -> 'b t) -> ('a -> ('b, string) Result.t) t

factor f creates a decoder which returns a function which finishes applying the decoder returned by f with a given argument

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

Monadic mapping operation

Sourceval map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

Maps the results of 2 decoders

Sourceval pair : 'a t -> 'b t -> ('a * 'b) t

Combine the results of 2 decoders to a pair

Sourceval fail : string -> 'a t

fail msg is a decoder which always fails with message msg

Sourceval try_ : 'a t -> 'a option t

try_ d is a decoder which returns None if d fails

Sourceval string : string t

Decode a JS string to an OCaml string

Sourceval int : int t

Decode a JS number to an OCaml integer

Sourceval float : float t

Decode a JS number to an OCaml float

Sourceval bool : bool t

Decode a JS boolean to an OCaml boolean

Sourceval unit : unit t

This decoder always returns ()

Sourceval object_ : js_object t

Decode a JS object to an OCaml representation

Sourceval list : 'a t -> 'a list t

list d decodes a JS array to an OCaml list, applying the decoder d to each element

Sourceval (let*) : 'a t -> ('a -> 'b t) -> 'b t
Sourceval (let+) : 'a t -> ('a -> 'b) -> 'b t
Sourceval (and+) : 'a t -> 'b t -> ('a * 'b) t
OCaml

Innovation. Community. Security.