disco-0.1.3.1: Functional programming language for teaching discrete math.
Copyrightdisco team and contributors
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellNone
LanguageHaskell2010

Disco.Pretty

Description

Various pretty-printing facilities for disco.

Synopsis

Documentation

class Pretty t where Source #

Methods

pretty :: Members '[Reader PA, LFresh] r => t -> Sem r Doc Source #

Instances

Instances details
Pretty TyOp Source # 
Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => TyOp -> Sem r Doc Source #

Pretty BOp Source #

Pretty-print a binary operator, by looking up its concrete syntax in the bopMap.

Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => BOp -> Sem r Doc Source #

Pretty UOp Source #

Pretty-print a unary operator, by looking up its concrete syntax in the uopMap.

Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => UOp -> Sem r Doc Source #

Pretty Qualifier Source # 
Instance details

Defined in Disco.Types.Qualifiers

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Qualifier -> Sem r Doc Source #

Pretty PolyType Source #

Pretty-print a polytype. Note that we never explicitly print forall; quantification is implicit, as in Haskell.

Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => PolyType -> Sem r Doc Source #

Pretty Type Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Type -> Sem r Doc Source #

Pretty Con Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Con -> Sem r Doc Source #

Pretty UAtom Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => UAtom -> Sem r Doc Source #

Pretty Atom Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Atom -> Sem r Doc Source #

Pretty Ilk Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Ilk -> Sem r Doc Source #

Pretty BaseTy Source # 
Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => BaseTy -> Sem r Doc Source #

Pretty ModuleName Source # 
Instance details

Defined in Disco.Names

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => ModuleName -> Sem r Doc Source #

Pretty Side Source # 
Instance details

Defined in Disco.AST.Generic

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Side -> Sem r Doc Source #

Pretty Pattern Source # 
Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Pattern -> Sem r Doc Source #

Pretty Guard Source # 
Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Guard -> Sem r Doc Source #

Pretty Branch Source #

Pretty-print a single branch in a case expression.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Branch -> Sem r Doc Source #

Pretty Binding Source #

Pretty-print a binding, i.e. a pairing of a name (with optional type annotation) and term.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Binding -> Sem r Doc Source #

Pretty Qual Source #

Pretty-print a single qualifier in a comprehension.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Qual -> Sem r Doc Source #

Pretty Term Source # 
Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Term -> Sem r Doc Source #

Pretty Decl Source # 
Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Decl -> Sem r Doc Source #

Pretty ATerm Source # 
Instance details

Defined in Disco.AST.Typed

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => ATerm -> Sem r Doc Source #

Pretty Op Source # 
Instance details

Defined in Disco.AST.Core

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Op -> Sem r Doc Source #

Pretty Core Source # 
Instance details

Defined in Disco.AST.Core

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Core -> Sem r Doc Source #

Pretty Constraint Source # 
Instance details

Defined in Disco.Typecheck.Constraints

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Constraint -> Sem r Doc Source #

Pretty TyVarInfo Source # 
Instance details

Defined in Disco.Typecheck.Solve

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => TyVarInfo -> Sem r Doc Source #

Pretty SimpleConstraint Source # 
Instance details

Defined in Disco.Typecheck.Solve

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => SimpleConstraint -> Sem r Doc Source #

Pretty TyVarInfoMap Source # 
Instance details

Defined in Disco.Typecheck.Solve

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => TyVarInfoMap -> Sem r Doc Source #

Pretty RelMap Source # 
Instance details

Defined in Disco.Typecheck.Solve

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => RelMap -> Sem r Doc Source #

Pretty Defn Source # 
Instance details

Defined in Disco.Module

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Defn -> Sem r Doc Source #

Pretty DiscoError Source # 
Instance details

Defined in Disco.Error

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => DiscoError -> Sem r Doc Source #

Pretty a => Pretty [a] Source # 
Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => [a] -> Sem r Doc Source #

Pretty a => Pretty (Set a) Source # 
Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Set a -> Sem r Doc Source #

Pretty (Name a) Source # 
Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Name a -> Sem r Doc Source #

Pretty a => Pretty (Substitution a) Source # 
Instance details

Defined in Disco.Subst

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Substitution a -> Sem r Doc Source #

Pretty (QName a) Source # 
Instance details

Defined in Disco.Names

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => QName a -> Sem r Doc Source #

Pretty (Telescope Guard) Source #

Pretty-print the guards in a single branch of a case expression.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Telescope Guard -> Sem r Doc Source #

Pretty (Telescope Qual) Source #

Pretty-print the qualifiers in a comprehension.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Telescope Qual -> Sem r Doc Source #

Pretty a => Pretty (Graph a) Source # 
Instance details

Defined in Disco.Typecheck.Graph

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Graph a -> Sem r Doc Source #

Pretty (String, TyDefBody) Source #

Pretty-print a type definition.

Instance details

Defined in Disco.Types

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => (String, TyDefBody) -> Sem r Doc Source #

Pretty (Name a, Bind [Pattern] Term) Source #

Pretty-print a single clause in a definition.

Instance details

Defined in Disco.AST.Surface

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => (Name a, Bind [Pattern] Term) -> Sem r Doc Source #

(Pretty k, Pretty v) => Pretty (Map k v) Source # 
Instance details

Defined in Disco.Pretty

Methods

pretty :: forall (r :: EffectRow). Members '[Reader PA, LFresh] r => Map k v -> Sem r Doc Source #

withPA :: Member (Reader PA) r => PA -> Sem r Doc -> Sem r Doc Source #

Convenience function combining setPA and mparens, since we often want to simultaneously indicate what the precedence and associativity of a term is, and optionally surround it with parentheses depending on the precedence and associativity of its parent.

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).

pretty' :: Pretty t => t -> Sem r Doc Source #

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.

findRep :: Ord a => [a] -> ([a], Int) Source #

findRep' :: Ord a => Map a Int -> Int -> [a] -> ([a], Int) Source #

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.

data Doc #

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

Instances details
Eq Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

(==) :: Doc -> Doc -> Bool #

(/=) :: Doc -> Doc -> Bool #

Show Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

showsPrec :: Int -> Doc -> ShowS #

show :: Doc -> String #

showList :: [Doc] -> ShowS #

IsString Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

fromString :: String -> Doc #

Generic Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Associated Types

type Rep Doc :: Type -> Type #

Methods

from :: Doc -> Rep Doc x #

to :: Rep Doc x -> Doc #

Semigroup Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

(<>) :: Doc -> Doc -> Doc #

sconcat :: NonEmpty Doc -> Doc #

stimes :: Integral b => b -> Doc -> Doc #

Monoid Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

mempty :: Doc #

mappend :: Doc -> Doc -> Doc #

mconcat :: [Doc] -> Doc #

NFData Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

Methods

rnf :: Doc -> () #

IsString (Sem r Doc) Source # 
Instance details

Defined in Disco.Pretty.DSL

Methods

fromString :: String -> Sem r Doc #

type Rep Doc 
Instance details

Defined in Text.PrettyPrint.HughesPJ

type Rep Doc = D1 ('MetaData "Doc" "Text.PrettyPrint.HughesPJ" "pretty-1.1.3.6" 'True) (C1 ('MetaCons "Doc" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ()))))