Copyright | disco team and contributors |
---|---|
License | BSD-3-Clause |
Maintainer | byorgey@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Various pretty-printing facilities for disco.
Synopsis
- module Disco.Pretty.DSL
- class Pretty t where
- withPA :: Member (Reader PA) r => PA -> Sem r Doc -> Sem r Doc
- setPA :: Member (Reader PA) r => PA -> Sem r a -> Sem r a
- lt :: Member (Reader PA) r => Sem r Doc -> Sem r Doc
- rt :: Member (Reader PA) r => Sem r Doc -> Sem r Doc
- mparens :: Member (Reader PA) r => PA -> Sem r Doc -> Sem r Doc
- prettyStr :: Pretty t => t -> Sem r String
- pretty' :: Pretty t => t -> Sem r Doc
- prettyDecimal :: Rational -> String
- findRep :: Ord a => [a] -> ([a], Int)
- findRep' :: Ord a => Map a Int -> Int -> [a] -> ([a], Int)
- digitalExpansion :: Integer -> Integer -> Integer -> ([Integer], Int)
- module Disco.Pretty.Prec
- data Doc
Documentation
module Disco.Pretty.DSL
Instances
Pretty TyOp Source # | |
Pretty BOp Source # | Pretty-print a binary operator, by looking up its concrete syntax
in the |
Pretty UOp Source # | Pretty-print a unary operator, by looking up its concrete syntax
in the |
Pretty Qualifier Source # | |
Pretty PolyType Source # | Pretty-print a polytype. Note that we never explicitly print
|
Pretty Type Source # | |
Pretty Con Source # | |
Pretty UAtom Source # | |
Pretty Atom Source # | |
Pretty Ilk Source # | |
Pretty BaseTy Source # | |
Pretty ModuleName Source # | |
Pretty Side Source # | |
Pretty Pattern Source # | |
Pretty Guard Source # | |
Pretty Branch Source # | Pretty-print a single branch in a case expression. |
Pretty Binding Source # | Pretty-print a binding, i.e. a pairing of a name (with optional type annotation) and term. |
Pretty Qual Source # | Pretty-print a single qualifier in a comprehension. |
Pretty Term Source # | |
Pretty Decl Source # | |
Pretty ATerm Source # | |
Pretty Op Source # | |
Pretty Core Source # | |
Pretty Constraint Source # | |
Pretty TyVarInfo Source # | |
Pretty SimpleConstraint Source # | |
Pretty TyVarInfoMap Source # | |
Pretty RelMap Source # | |
Pretty Defn Source # | |
Pretty DiscoError Source # | |
Pretty a => Pretty [a] Source # | |
Pretty a => Pretty (Set a) Source # | |
Pretty (Name a) Source # | |
Pretty a => Pretty (Substitution a) Source # | |
Pretty (QName a) Source # | |
Pretty (Telescope Guard) Source # | Pretty-print the guards in a single branch of a case expression. |
Pretty (Telescope Qual) Source # | Pretty-print the qualifiers in a comprehension. |
Pretty a => Pretty (Graph a) Source # | |
Pretty (String, TyDefBody) Source # | Pretty-print a type definition. |
Pretty (Name a, Bind [Pattern] Term) Source # | Pretty-print a single clause in a definition. |
(Pretty k, Pretty v) => Pretty (Map k v) Source # | |
setPA :: Member (Reader PA) r => PA -> Sem r a -> Sem r a Source #
Locally set the precedence and associativity within a subcomputation.
lt :: Member (Reader PA) r => Sem r Doc -> Sem r Doc Source #
Mark a subcomputation as pretty-printing a term on the left of an operator (so parentheses can be inserted appropriately, depending on the associativity).
rt :: Member (Reader PA) r => Sem r Doc -> Sem r Doc Source #
Mark a subcomputation as pretty-printing a term on the right of an operator (so parentheses can be inserted appropriately, depending on the associativity).
mparens :: Member (Reader PA) r => PA -> Sem r Doc -> Sem r Doc Source #
Optionally surround a pretty-printed term with parentheses,
depending on its precedence and associativity (given as the PA
argument) and that of its context (given by the ambient 'Reader
PA' effect).
prettyDecimal :: Rational -> String Source #
Pretty-print a rational number using its decimal expansion, in
the format nnn.prefix[rep]...
, with any repeating digits enclosed
in square brackets.
digitalExpansion :: Integer -> Integer -> Integer -> ([Integer], Int) Source #
digitalExpansion b n d
takes the numerator and denominator of a
fraction n/d between 0 and 1, and returns a pair of (1) a list of
digits ds
, and (2) a nonnegative integer k such that splitAt k
ds = (prefix, rep)
, where the infinite base-b expansion of
n/d is 0.(prefix ++ cycle rep)
. For example,
digitalExpansion 10 1 4 = ([2,5,0], 2) digitalExpansion 10 1 7 = ([1,4,2,8,5,7], 0) digitalExpansion 10 3 28 = ([1,0,7,1,4,2,8,5], 2) digitalExpansion 2 1 5 = ([0,0,1,1], 0)
It works by performing the standard long division algorithm, and looking for the first time that the remainder repeats.
module Disco.Pretty.Prec
The abstract type of documents. A Doc represents a set of layouts. A Doc with no occurrences of Union or NoDoc represents just one layout.
Instances
Eq Doc | |
Show Doc | |
IsString Doc | |
Defined in Text.PrettyPrint.HughesPJ fromString :: String -> Doc # | |
Generic Doc | |
Semigroup Doc | |
Monoid Doc | |
NFData Doc | |
Defined in Text.PrettyPrint.HughesPJ | |
IsString (Sem r Doc) Source # | |
Defined in Disco.Pretty.DSL fromString :: String -> Sem r Doc # | |
type Rep Doc | |
Defined in Text.PrettyPrint.HughesPJ |