<commit_before>*********************************************************************************
*										*
*	<NAME> and <NAME>'s Pretty Printer Combinators	*
*										*
*		based on "The Design of a Pretty-printing Library"		*
*		in Advanced Functional Programming, 				*
*		<NAME> and <NAME> (eds), LNCS 925 			*
* 		http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps		*
*										*
*		Heavily modified by <NAME>, Dec 96			*
*										*
*********************************************************************************

Version 2.0	24 April 1997
  * Made empty into a left unit for <> as well as a right unit;
    it is also now true that
	nest k empty = empty
    which wasn't true before.

  * Fixed an obscure bug in sep that occassionally gave very wierd behaviour

  * Added $+$

  * Corrected and tidied up the laws and invariants

======================================================================
Relative to John's original paper, there are the following new features:

1.  There's an empty document, "empty".  It's a left and right unit for 
    both <> and $$, and anywhere in the argument list for
    sep, hcat, hsep, vcat, fcat etc.

    It is Really Useful in practice.

2.  There is a paragraph-fill combinator, fsep, that's much like sep,
    only it keeps fitting things on one line until itc can't fit any more.

3.  Some random useful extra combinators are provided.  
	<+> puts its arguments beside each other with a space between them,
	    unless either argument is empty in which case it returns the other


	hcat is a list version of <>
	hsep is a list version of <+>
	vcat is a list version of $$

	sep (separate) is either like hsep or like vcat, depending on what fits

	cat  is behaves like sep,  but it uses <> for horizontal conposition
	fcat is behaves like fsep, but it uses <> for horizontal conposition

	These new ones do the obvious things:
		char, semi, comma, colon, space,
		parens, brackets, braces, 
		quotes, doubleQuotes
	
4.	The "above" combinator, $$, now overlaps its two arguments if the
	last line of the top argument stops before the first line of the second begins.
	For example:  text "hi" $$ nest 5 "there"
	lays out as
			hi   there
	rather than
			hi
			     there

	There are two places this is really useful

	a) When making labelled blocks, like this:
		Left ->   code for left
	        Right ->  code for right
		LongLongLongLabel ->
			  code for longlonglonglabel
	   The block is on the same line as the label if the label is
	   short, but on the next line otherwise.

	b) When laying out lists like this:
		[ first
		, second
		, third
		]
	   which some people like.  But if the list fits on one line
	   you want [first, second, third].  You can't do this with
	   John's original combinators, but it's quite easy with the
	   new $$.

	The combinator $+$ gives the original "never-overlap" behaviour.

5.	Several different renderers are provided:
		* a standard one
		* one that uses cut-marks to avoid deeply-nested documents 
			simply piling up in the right-hand margin
		* one that ignores indentation (fewer chars output; good for machines)
		* one that ignores indentation and newlines (ditto, only more so)

6.	Numerous implementation tidy-ups
	Use of unboxed data types to speed up the implementation



\begin{code}
#include "HsVersions.h"

module Pretty (
	Doc, 		-- Abstract
	Mode(..), TextDetails(..),

	empty, nest,

	text, char, ptext,
	int, integer, float, double, rational,
	parens, brackets, braces, quotes, doubleQuotes,
	semi, comma, colon, space, equals,
	lparen, rparen, lbrack, rbrack, lbrace, rbrace,

	(<>), (<+>), hcat, hsep, 
	($$), ($+$), vcat, 
	sep, cat, 
	fsep, fcat, 

	hang, punctuate,
	
--	renderStyle,		-- Haskell 1.3 only
	render, fullRender
  ) where

#include "HsVersions.h"
#if defined(__GLASGOW_HASKELL__)

import FastString
IMP_Ubiq()

#if __GLASGOW_HASKELL__ >= 202
import GHC
import PrelBase
#endif
#endif


import Util	( assertPanic )

infixl 6 <> 
infixl 6 <+>
infixl 5 $$, $+$
\end{code}



*********************************************************
*							*
\subsection{CPP magic so that we can compile with both GHC and Hugs}
*							*
*********************************************************
<commit_msg>[project @ 1997-05-26 01:15:21 by sof] Updated imports<commit_after>*********************************************************************************
*										*
*	<NAME> and <NAME>'s Pretty Printer Combinators	*
*										*
*		based on "The Design of a Pretty-printing Library"		*
*		in Advanced Functional Programming, 				*
*		<NAME> and <NAME> (eds), LNCS 925 			*
* 		http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps		*
*										*
*		Heavily modified by <NAME>, Dec 96			*
*										*
*********************************************************************************

Version 2.0	24 April 1997
  * Made empty into a left unit for <> as well as a right unit;
    it is also now true that
	nest k empty = empty
    which wasn't true before.

  * Fixed an obscure bug in sep that occassionally gave very wierd behaviour

  * Added $+$

  * Corrected and tidied up the laws and invariants

======================================================================
Relative to John's original paper, there are the following new features:

1.  There's an empty document, "empty".  It's a left and right unit for 
    both <> and $$, and anywhere in the argument list for
    sep, hcat, hsep, vcat, fcat etc.

    It is Really Useful in practice.

2.  There is a paragraph-fill combinator, fsep, that's much like sep,
    only it keeps fitting things on one line until itc can't fit any more.

3.  Some random useful extra combinators are provided.  
	<+> puts its arguments beside each other with a space between them,
	    unless either argument is empty in which case it returns the other


	hcat is a list version of <>
	hsep is a list version of <+>
	vcat is a list version of $$

	sep (separate) is either like hsep or like vcat, depending on what fits

	cat  is behaves like sep,  but it uses <> for horizontal conposition
	fcat is behaves like fsep, but it uses <> for horizontal conposition

	These new ones do the obvious things:
		char, semi, comma, colon, space,
		parens, brackets, braces, 
		quotes, doubleQuotes
	
4.	The "above" combinator, $$, now overlaps its two arguments if the
	last line of the top argument stops before the first line of the second begins.
	For example:  text "hi" $$ nest 5 "there"
	lays out as
			hi   there
	rather than
			hi
			     there

	There are two places this is really useful

	a) When making labelled blocks, like this:
		Left ->   code for left
	        Right ->  code for right
		LongLongLongLabel ->
			  code for longlonglonglabel
	   The block is on the same line as the label if the label is
	   short, but on the next line otherwise.

	b) When laying out lists like this:
		[ first
		, second
		, third
		]
	   which some people like.  But if the list fits on one line
	   you want [first, second, third].  You can't do this with
	   John's original combinators, but it's quite easy with the
	   new $$.

	The combinator $+$ gives the original "never-overlap" behaviour.

5.	Several different renderers are provided:
		* a standard one
		* one that uses cut-marks to avoid deeply-nested documents 
			simply piling up in the right-hand margin
		* one that ignores indentation (fewer chars output; good for machines)
		* one that ignores indentation and newlines (ditto, only more so)

6.	Numerous implementation tidy-ups
	Use of unboxed data types to speed up the implementation



\begin{code}
#include "HsVersions.h"

module Pretty (
	Doc, 		-- Abstract
	Mode(..), TextDetails(..),

	empty, nest,

	text, char, ptext,
	int, integer, float, double, rational,
	parens, brackets, braces, quotes, doubleQuotes,
	semi, comma, colon, space, equals,
	lparen, rparen, lbrack, rbrack, lbrace, rbrace,

	(<>), (<+>), hcat, hsep, 
	($$), ($+$), vcat, 
	sep, cat, 
	fsep, fcat, 

	hang, punctuate,
	
--	renderStyle,		-- Haskell 1.3 only
	render, fullRender
  ) where

#include "HsVersions.h"
#if defined(__GLASGOW_HASKELL__)

import FastString

#if __GLASGOW_HASKELL__ >= 202

import GlaExts

#else

	-- Horrible import to satisfy GHC 0.29
import Ubiq		( Unique, Uniquable(..), Name )

#endif
#endif

-- Don't import Util( assertPanic ) because it makes a loop in the module structure

infixl 6 <> 
infixl 6 <+>
infixl 5 $$, $+$
\end{code}



*********************************************************
*							*
\subsection{CPP magic so that we can compile with both GHC and Hugs}
*							*
*********************************************************

{'fraction_non_alphanumeric': 0.15673545096220728, 'fraction_numerical': 0.008462786923255274, 'mean_word_length': 3.4150460593654044, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7531355', 'n_tokens_mistral': 2965, 'n_tokens_neox': 2557, 'n_words': 1109}