glitr_convert/converter

Types

pub opaque type Converter(a)
pub opaque type ObjectConverter(current, base)
pub opaque type ObjectWithFieldConverter(current, base)

Functions

pub fn bool() -> Converter(Bool)
pub fn constructor(c: fn() -> a) -> ObjectConverter(Nil, a)
pub fn decode(
  converter: Converter(a),
  value: GlitrValue,
) -> Result(a, List(DecodeError))
pub fn dict(
  key: Converter(a),
  value: Converter(b),
) -> Converter(Dict(a, b))
pub fn encode(
  converter: Converter(a),
  value: a,
) -> Result(GlitrValue, List(DecodeError))
pub fn enum(
  tags: fn(a) -> String,
  converters: List(#(String, Converter(a))),
) -> Converter(a)
pub fn field(
  converter: ObjectWithFieldConverter(#(a, b), c),
  field_name: String,
  field_getter: fn(c) -> Result(a, Nil),
  field_type: Converter(a),
) -> ObjectWithFieldConverter(b, c)
pub fn float() -> Converter(Float)
pub fn int() -> Converter(Int)
pub fn json_decode(
  converter: Converter(a),
  value: Dynamic,
) -> Result(a, List(DecodeError))
pub fn json_encode(
  converter: Converter(a),
  value: a,
) -> Result(Json, List(DecodeError))
pub fn list(of: Converter(a)) -> Converter(List(a))
pub fn null() -> Converter(Nil)
pub fn object(
  object_converter: ObjectConverter(a, b),
) -> ObjectWithFieldConverter(a, b)
pub fn optional(of: Converter(a)) -> Converter(Option(a))
pub fn parameter(
  next: fn(a) -> ObjectConverter(b, c),
) -> ObjectConverter(#(a, b), c)
pub fn result(
  res: Converter(a),
  error: Converter(b),
) -> Converter(Result(a, b))
pub fn string() -> Converter(String)
pub fn to_converter(
  converter: ObjectWithFieldConverter(Nil, a),
) -> Converter(a)
Search Document