package yocaml

  1. Overview
  2. Docs

Infix operators are essentially used to compose data validators (unlike binding operators, which are used to compose record validation fragments).

Infix operators are used to trivially compose validators. If you have a complicated set of validation rules, it is advisable to build a dedicated function to avoid making the validation rule complex to read.

val (&) : ('a -> 'b validated_value) -> ('b -> 'c validated_value) -> 'a -> 'c validated_value

(v1 & v2) x sequentially compose v2 (v1 x), so v1 following by v2. For example : int &> positive &> c.

val (/) : ('a -> 'b validated_value) -> ('a -> 'b validated_value) -> 'a -> 'b validated_value

(v1 / v2) x perform v1 x and if it fail, performs v2 x.

val ($) : ('a -> 'b validated_value) -> ('b -> 'c) -> 'a -> 'c validated_value

(v1 $ f) x perform f on the result of v1 x.

OCaml

Innovation. Community. Security.