package alg_structs

  1. Overview
  2. Docs

Law notes the laws that should be obeyed by any instantiation of Functor in the form of predicates that should be true for any arguments of the appropriate type.

See wikipedia's definition functors for the mathematical expression of these properties.

You can use Alg_qcheck.Functor to generate property based tests of these laws for new modules satisfying this interface.

  • parameter F

    An implementation of a Functor

Parameters

module F : S

Signature

val identity : 'a F.t -> bool

identity x is true when

F.map ~f:Fun.id x = Fun.id x
val composition : ('a -> 'b) -> ('c -> 'a) -> 'c F.t -> bool

composition f g x is true when

F.map ~f:(f % g) x = (F.map ~f % F.map ~f:g) x

where % is composition.

OCaml

Innovation. Community. Security.