<commit_before>{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
             GeneralizedNewtypeDeriving, DeriveFoldable, DeriveTraversable,
             DeriveFunctor, ScopedTypeVariables #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Text.PrettyPrint.JPP
-- Copyright   :  <NAME> (c) 2013
--
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  <EMAIL>
-- Stability   :  experimental
-- Portability :  no
--
-- Pretty print module based on a new algorithm for formatting the document
-- abstraction of Daan Leijen and <NAME>adler. The document abstraction (but
-- not this algorithm) is described in:
--
-- @
--      \"A prettier printer\"
--      Draft paper, April 1997, revised March 1998.
--      <http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf>
-- @
--
-- * The 'Doc' abstraction
--
-- The 'Doc' data structure is an abstraction between ASTs and plain text that
-- separates the problem of translating nodes in an AST into pieces of text (a
-- local operation) from formatting these text pieces on a page (a global
-- operation). In particular, this library allows an AST to be pretty printed in
-- two phases:
--
--   1) The AST is translated into a 'Doc', using the cost system to encode
--   style preferences in the object language, such as at which positions it is
--   prefereable to insert linebreaks, how the indentation is affected by
--   different syntactic structures, etc.
--
--   2) There may be many ways to format a particular 'Doc', each with an
--   associated cost. The algorithm implemented here formats a 'Doc' into a
--   piece of text with minimal global cost.
--
-- The algebric properties of the 'Doc' data structure are central to this
-- algorithm for rendering them. In particular, if 'c' is a semiring and 't' a
-- monoid, 'Doc c t' is a semiring with additive operator '+', multiplicative
-- operator '*', additive identity '0', and multiplicative identity '1':
--
--   - '0' is a document that can not be rendered
--   - '1' is a document corresponding to \epsilon
--   - 'x' + 'y' is a document that may be rendered either as 'x' or as 'y'.
--   - 'x' * 'y' i sa document rendered as 'x' concatenated with 'y'.
--
-- It is easy to see that the semiring axioms hold on this structure.
-- Consequently, this library exports an instance of 'Num (Doc c t)'.
--
-- Several other primitives are required to represent most programming
-- languages; combinators encapsulating them are described (with examples) in
-- the combinators section below.

-- TODO(sjindel): Add documentation everywhere.
-- TODO(sjindel): Use hash-consing of the 'Doc's to improve memoization reuse.

module Text.PrettyPrint.JPP
  ( -- Classes
    Long(..)
  , TextLike(..)
    -- Types
  , Doc
  , DocCost(..)
    -- Combinators
  , align
  , column
  , cost
  , tag
  , flatAlt
  , flatten
  , hfill
  , line
  , nest
  , nesting
  , pagewidth
  , ref
  , sep
  , text
    -- Rendering/displaying functions
  , display<commit_msg>remembered that I had a better name for the algorithm<commit_after>{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
             GeneralizedNewtypeDeriving, DeriveFoldable, DeriveTraversable,
             DeriveFunctor, ScopedTypeVariables #-}
--------------------------------------------------------------------------------
-- |
-- Module      :  Text.PrettyPrint.Lotus
-- Copyright   :  <NAME> (c) 2013
--
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  <EMAIL>
-- Stability   :  experimental
-- Portability :  no
--
-- Pretty print module based on a new algorithm for formatting the document
-- abstraction of Daan Leijen and <NAME>. The document abstraction (but
-- not this algorithm) is described in:
--
-- @
--      \"A prettier printer\"
--      Draft paper, April 1997, revised March 1998.
--      <http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf>
-- @
--
-- * The 'Doc' abstraction
--
-- The 'Doc' data structure is an abstraction between ASTs and plain text that
-- separates the problem of translating nodes in an AST into pieces of text (a
-- local operation) from formatting these text pieces on a page (a global
-- operation). In particular, this library allows an AST to be pretty printed in
-- two phases:
--
--   1) The AST is translated into a 'Doc', using the cost system to encode
--   style preferences in the object language, such as at which positions it is
--   prefereable to insert linebreaks, how the indentation is affected by
--   different syntactic structures, etc.
--
--   2) There may be many ways to format a particular 'Doc', each with an
--   associated cost. The algorithm implemented here formats a 'Doc' into a
--   piece of text with minimal global cost.
--
-- The algebric properties of the 'Doc' data structure are central to this
-- algorithm for rendering them. In particular, if 'c' is a semiring and 't' a
-- monoid, 'Doc c t' is a semiring with additive operator '+', multiplicative
-- operator '*', additive identity '0', and multiplicative identity '1':
--
--   - '0' is a document that can not be rendered
--   - '1' is a document corresponding to \epsilon
--   - 'x' + 'y' is a document that may be rendered either as 'x' or as 'y'.
--   - 'x' * 'y' i sa document rendered as 'x' concatenated with 'y'.
--
-- It is easy to see that the semiring axioms hold on this structure.
-- Consequently, this library exports an instance of 'Num (Doc c t)'.
--
-- Several other primitives are required to represent most programming
-- languages; combinators encapsulating them are described (with examples) in
-- the combinators section below.

-- TODO(sjindel): Add documentation everywhere.
-- TODO(sjindel): Use hash-consing of the 'Doc's to improve memoization reuse.

module Text.PrettyPrint.Lotus
  ( -- Classes
    Long(..)
  , TextLike(..)
    -- Types
  , Doc
  , DocCost(..)
    -- Combinators
  , align
  , column
  , cost
  , tag
  , flatAlt
  , flatten
  , hfill
  , line
  , nest
  , nesting
  , pagewidth
  , ref
  , sep
  , text
    -- Rendering/displaying functions
  , display
{'fraction_non_alphanumeric': 0.1313375181071946, 'fraction_numerical': 0.005794302269435055, 'mean_word_length': 2.591907514450867, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2685481', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1762, 'n_words': 750}