MakeCompat.C
The cost factory interface.
A valid cost factory should also satisfy the following contracts.
le
is a total ordering.le a b
and le c d
then le (combine a c) (combine b d)
a
<= b
, then le (text a l) (text b l)
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
a
<= b
, then le (two_columns_overflow a) (two_columns_overflow b)
a
<= b
, then le (two_columns_bias a) (two_columns_bias b)
See default_cost_factory
, the cost factory section, and the paper for examples of cost factories.
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 two_columns_bias : int -> t
two_columns_bias i
is the bias cost, added to each possible column separator so that the leftmost column separator is preferred.
val two_columns_overflow : int -> t
two_columns_overflow i
is the cost due to exceeding the column separator. Make this cost greater than the usual overflow cost (for exceeding the page width limit) to prefer going over the page width limit instead of going over the column separator.
limit
is the computation width limit.
val string_of_cost : t -> string
string_of_cost c
produces a string representation of a cost c