package pretty_expressive
A pretty expressive printer
Install
Dune Dependency
Authors
Maintainers
Sources
pretty_expressive-0.4.tbz
sha256=d5192e8dc99348aa2a2924672f8f122c5953e8c5d9b5b37abee59e6c25487995
sha512=d9a2cebc18a48b64ee87027063cb17386e22da126e6a1cab065ba9f9e6ce26837813234dc303f4a5e16c45de6f1f9ee0b8d2bdeba07667de779b1693862c1399
doc/pretty_expressive/Pretty_expressive/Printer/index.html
Module Pretty_expressive.Printer
Source
This module provides a pretty expressive printer.
The pretty printer and document combinators, parameterized by a cost factory.
This functor is similar to Make
, but it provides operators that are compatible with the paper. Using open
on it will shadow built-in identifiers.
make_debug_format limit content is_tainted cost
returns a debugging string containing these parameters.
Source
val default_cost_factory :
page_width:int ->
?computation_width:int ->
unit ->
(module Signature.CostFactory
with type t = int * int * int)
The default cost factory, parameterized by the page width limit page_width
, and optionally the computation width limit computation_width
. When the computation width limit is not specified, it is set to 1.2 * page_width
.
In this cost factory, the cost type t
is a quadruple of natural numbers.
- The first component is badness, which is roughly speaking the sum of squared overflows over the page width limit
- The second component is sum of overflows over a column separator.
- The third component is the height (number of newlines).
Internally, default_cost_factory
is defined as:
let default_cost_factory ~page_width ?computation_width () =
(module struct
type t = int * int * int
let limit = match computation_width with
| None -> (float_of_int page_width) *. 1.2 |> int_of_float
| Some computation_width -> computation_width
let text pos len =
let stop = pos + len in
if stop > page_width then
let maxwc = max page_width pos in
let a = maxwc - page_width in
let b = stop - maxwc in
(b * (2*a + b), 0, 0)
else
(0, 0, 0)
let newline _ = (0, 0, 1)
let combine (o1, ot1, h1) (o2, ot2, h2) =
(o1 + o2, ot1 + ot2, h1 + h2)
let le c1 c2 = c1 <= c2
let two_columns_overflow w = (0, w, 0)
let two_columns_bias _ = (0, 0, 0)
let string_of_cost (o, ot, h) = Printf.sprintf "(%d %d %d)" o ot h
let debug_format = make_debug_format page_width
end: Signature.CostFactory with type t = int * int * int)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>