package pretty_expressive

  1. Overview
  2. Docs

The cost factory interface.

A valid cost factory should also satisfy the following contracts.

  • le is a total ordering.
  • If le a b and le c d then le (combine a c) (combine b d)
  • If a <= b, then le (text a l) (text b l)
  • If a <= b, then le (newline a) (newline b)
  • text c (a + b) = combine (text c a) (text (c + a) b)
  • combine is associative and has the identity equal to text 0 0
  • text c 0 = text 0 0 for any c

See default_cost_factory, the cost factory section, and the paper for examples of cost factories.

type t

A type for cost

val text : int -> int -> t

text c l calculates a cost for a text placement at column position c with length l

val newline : int -> t

newline i calculates a cost for a newline and indentation at level i

val combine : t -> t -> t

combine x y combines the costs x and y together

val le : t -> t -> bool

le x y tests if the cost x is less than or equal to the cost y.

val limit : int

limit is the computation width limit.

val debug : t -> string

debug c produces a string representation of a cost c

OCaml

Innovation. Community. Security.