package profunctor

  1. Overview
  2. Docs

A profunctor which represents a function where Fn.id may sometimes be distinguished from other functions.

This is primarily used internally to implement other things where discarding identity functions can be advantageous.

type ('b, 'a) t =
  1. | Id : ('a, 'a) t
  2. | Apply : ('a -> 'b) -> ('b, 'a) t
include S with type ('b, 'a) t := ('b, 'a) t
val map : ('a, 'u) t -> f:('a -> 'b) -> ('b, 'u) t
val contra_map : ('u, 'b) t -> f:('a -> 'b) -> ('u, 'a) t
val both : ('a, 'i) t -> ('b, 'i) t -> ('a * 'b, 'i) t
val id : ('a, 'a) t
val of_fn : ('a -> 'b) -> ('b, 'a) t
val as_fn : ('b, 'a) t -> ('a -> 'b) Base.Staged.t

Unpack the function, as_fn (of_fn x) ≡ Staged.stage x.

val split : ('b, 'a) t -> ('d, 'c) t -> ('b * 'd, 'a * 'c) t

split l r ≡ both (contra_map ~f:fst l) (contra_map ~f:snd r), but is more efficient (the result may be Id).

val compose : ('c, 'b) t -> ('b, 'a) t -> ('c, 'a) t

Composition of function, as_fn (compose g f) ≡ Fn.compose (as_fn g) (as_fn f).

module Of_record : Record_builder with type ('b, 'a) profunctor = ('b, 'a) t and type 'a profunctor_term = ('a, 'a) t
OCaml

Innovation. Community. Security.