package decoders-yojson

  1. Overview
  2. Docs

Pipeline Decoders

Pipeline decoders present an alternative to the mapN style. They read more naturally, but can lead to harder-to-understand type errors.

let person_decoder : person decoder =
  decode as_person
  |> required "name" string
  |> required "age" int
val decode : 'a -> 'a decoder
val required : string -> 'a decoder -> ('a -> 'b) decoder -> 'b decoder
val required_at : string list -> 'a decoder -> ('a -> 'b) decoder -> 'b decoder
val optional : string -> 'a decoder -> 'a -> ('a -> 'b) decoder -> 'b decoder
val optional_at : string list -> 'a decoder -> 'a -> ('a -> 'b) decoder -> 'b decoder
val custom : 'a decoder -> ('a -> 'b) decoder -> 'b decoder
OCaml

Innovation. Community. Security.