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.
val text : int -> int -> t
text c l
calculates a cost for a text placement at column position c
with length l
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
le x y
tests if the cost x
is less than or equal to the cost y
.
limit
is the computation width limit.
debug c
produces a string representation of a cost c