| Copyright | (c) 2013-2016 Galois Inc. |
|---|---|
| License | BSD3 |
| Maintainer | cryptol@galois.com |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Cryptol.Utils.PP
Description
Synopsis
- data PPOpts = PPOpts {
- useAscii :: Bool
- useBase :: Int
- useInfLength :: Int
- useFPBase :: Int
- useFPFormat :: PPFloatFormat
- useFieldOrder :: FieldOrder
- asciiMode :: PPOpts -> Integer -> Bool
- data PPFloatFormat
- data PPFloatExp
- data FieldOrder
- defaultPPOpts :: PPOpts
- data NameDisp
- = EmptyNameDisp
- | NameDisp (OrigName -> Maybe NameFormat)
- data NameFormat
- neverQualifyMod :: ModPath -> NameDisp
- neverQualify :: NameDisp
- extend :: NameDisp -> NameDisp -> NameDisp
- getNameFormat :: OrigName -> NameDisp -> NameFormat
- withNameDisp :: (NameDisp -> Doc) -> Doc
- withPPCfg :: (PPCfg -> Doc) -> Doc
- fixNameDisp :: NameDisp -> Doc -> Doc
- fixPPCfg :: PPCfg -> Doc -> Doc
- updPPCfg :: (PPCfg -> PPCfg) -> Doc -> Doc
- debugShowUniques :: Doc -> Doc
- setAnnotStyle :: AnnotStyle -> Doc -> Doc
- data PPCfg = PPCfg {}
- defaultPPCfg :: PPCfg
- data PPAnnot = AnnError
- data AnnotStyle
- type PPDoc = Doc (AnnotStyle, PPAnnot)
- newtype Doc = Doc (PPCfg -> PPDoc)
- runDocWith :: PPCfg -> Doc -> PPDoc
- runDoc :: NameDisp -> Doc -> PPDoc
- renderString :: SimpleDocStream (AnnotStyle, PPAnnot) -> String
- renderOneLine :: Doc -> String
- class PP a where
- class PP a => PPName a where
- ppNameFixity :: a -> Maybe Fixity
- ppPrefixName :: a -> Doc
- ppInfixName :: a -> Doc
- pp :: PP a => a -> Doc
- pretty :: PP a => a -> String
- optParens :: Bool -> Doc -> Doc
- data Infix op thing = Infix {}
- ppInfix :: (PP thing, PP op) => Int -> (thing -> Maybe (Infix op thing)) -> Infix op thing -> Doc
- ordinal :: (Integral a, Show a, Eq a) => a -> Doc
- ordSuffix :: (Integral a, Eq a) => a -> String
- liftPP :: PPDoc -> Doc
- liftPP1 :: (PPDoc -> PPDoc) -> Doc -> Doc
- liftPP2 :: (PPDoc -> PPDoc -> PPDoc) -> Doc -> Doc -> Doc
- liftSep :: ([PPDoc] -> PPDoc) -> [Doc] -> Doc
- reflow :: Text -> Doc
- annotate :: PPAnnot -> Doc -> Doc
- (<.>) :: Doc -> Doc -> Doc
- (<+>) :: Doc -> Doc -> Doc
- (</>) :: Doc -> Doc -> Doc
- ($$) :: Doc -> Doc -> Doc
- sep :: [Doc] -> Doc
- fsep :: [Doc] -> Doc
- hsep :: [Doc] -> Doc
- hcat :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- group :: Doc -> Doc
- hang :: Doc -> Int -> Doc -> Doc
- nest :: Int -> Doc -> Doc
- indent :: Int -> Doc -> Doc
- align :: Doc -> Doc
- parens :: Doc -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- quotes :: Doc -> Doc
- commaSep :: [Doc] -> Doc
- commaSepFill :: [Doc] -> Doc
- ppList :: [Doc] -> Doc
- ppTuple :: [Doc] -> Doc
- ppRecord :: [Doc] -> Doc
- backticks :: Doc -> Doc
- text :: String -> Doc
- char :: Char -> Doc
- integer :: Integer -> Doc
- int :: Int -> Doc
- comma :: Doc
- colon :: Doc
- pipe :: Doc
Documentation
How to pretty print things when evaluating
Constructors
| PPOpts | |
Fields
| |
data PPFloatFormat Source #
Constructors
| FloatFixed Int PPFloatExp | Use this many significant digis |
| FloatFrac Int | Show this many digits after floating point |
| FloatFree PPFloatExp | Use the correct number of digits |
Instances
| Show PPFloatFormat Source # | |
Defined in Cryptol.Utils.PP Methods showsPrec :: Int -> PPFloatFormat -> ShowS # show :: PPFloatFormat -> String # showList :: [PPFloatFormat] -> ShowS # | |
data PPFloatExp Source #
Constructors
| ForceExponent | Always show an exponent |
| AutoExponent | Only show exponent when needed |
Instances
| Show PPFloatExp Source # | |
Defined in Cryptol.Utils.PP Methods showsPrec :: Int -> PPFloatExp -> ShowS # show :: PPFloatExp -> String # showList :: [PPFloatExp] -> ShowS # | |
data FieldOrder Source #
Constructors
| DisplayOrder | |
| CanonicalOrder |
Instances
How to display names, inspired by the GHC Outputable module.
Getting a value of Nothing from the NameDisp function indicates
that the display has no opinion on how this name should be displayed,
and some other display should be tried out.
Constructors
| EmptyNameDisp | |
| NameDisp (OrigName -> Maybe NameFormat) |
Instances
data NameFormat Source #
Constructors
| UnQualified | |
| Qualified !ModName | |
| NotInScope |
Instances
| Show NameFormat Source # | |
Defined in Cryptol.Utils.PP Methods showsPrec :: Int -> NameFormat -> ShowS # show :: NameFormat -> String # showList :: [NameFormat] -> ShowS # | |
neverQualifyMod :: ModPath -> NameDisp Source #
Never qualify names from this module.
extend :: NameDisp -> NameDisp -> NameDisp Source #
Compose two naming environments, preferring names from the left environment.
getNameFormat :: OrigName -> NameDisp -> NameFormat Source #
Get the format for a name.
withNameDisp :: (NameDisp -> Doc) -> Doc Source #
Produce a document in the context of the current NameDisp.
withPPCfg :: (PPCfg -> Doc) -> Doc Source #
Produce a document in the context of the current configuration.
debugShowUniques :: Doc -> Doc Source #
setAnnotStyle :: AnnotStyle -> Doc -> Doc Source #
Constructors
| PPCfg | |
Fields | |
defaultPPCfg :: PPCfg Source #
Instances
renderString :: SimpleDocStream (AnnotStyle, PPAnnot) -> String Source #
renderOneLine :: Doc -> String Source #
Minimal complete definition
Methods
ppPrec :: Int -> a -> Doc Source #
ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> a -> Doc Source #
Pretty print something, annotating subterms as needed.
| Pretty print something, annotating subterms as needed.
The [Int] is supposed to indicate a path through the term in some
type specific way.
Instances
| PP EvalError Source # | |
| PP EvalErrorEx Source # | |
Defined in Cryptol.Backend.Monad Methods ppPrec :: Int -> EvalErrorEx -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> EvalErrorEx -> Doc Source # | |
| PP ImportErrorMessage Source # | |
Defined in Cryptol.Backend.Monad Methods ppPrec :: Int -> ImportErrorMessage -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ImportErrorMessage -> Doc Source # | |
| PP ImportThing Source # | |
Defined in Cryptol.Backend.Monad Methods ppPrec :: Int -> ImportThing -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ImportThing -> Doc Source # | |
| PP Unsupported Source # | |
Defined in Cryptol.Backend.Monad Methods ppPrec :: Int -> Unsupported -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> Unsupported -> Doc Source # | |
| PP WordTooWide Source # | |
Defined in Cryptol.Backend.Monad Methods ppPrec :: Int -> WordTooWide -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> WordTooWide -> Doc Source # | |
| PP FFILoadError Source # | |
Defined in Cryptol.Eval.FFI.Error Methods ppPrec :: Int -> FFILoadError -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> FFILoadError -> Doc Source # | |
| PP TValue Source # | |
| PP ModulePath Source # | |
Defined in Cryptol.ModuleSystem.Env Methods ppPrec :: Int -> ModulePath -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModulePath -> Doc Source # | |
| PP ImportSource Source # | |
Defined in Cryptol.ModuleSystem.Monad Methods ppPrec :: Int -> ImportSource -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ImportSource -> Doc Source # | |
| PP ModuleError Source # | |
Defined in Cryptol.ModuleSystem.Monad Methods ppPrec :: Int -> ModuleError -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleError -> Doc Source # | |
| PP ModuleWarning Source # | |
Defined in Cryptol.ModuleSystem.Monad Methods ppPrec :: Int -> ModuleWarning -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleWarning -> Doc Source # | |
| PP Name Source # | |
| PP NamingEnv Source # | |
| PP RenamedModule Source # | |
Defined in Cryptol.ModuleSystem.Renamer Methods ppPrec :: Int -> RenamedModule -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamedModule -> Doc Source # | |
| PP DepName Source # | |
| PP ModKind Source # | |
| PP RenamerError Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Error Methods ppPrec :: Int -> RenamerError -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamerError -> Doc Source # | |
| PP RenamerWarning Source # | |
Defined in Cryptol.ModuleSystem.Renamer.Error Methods ppPrec :: Int -> RenamerWarning -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> RenamerWarning -> Doc Source # | |
| PP ForeignMode Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ForeignMode -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ForeignMode -> Doc Source # | |
| PP ImportSpec Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ImportSpec -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ImportSpec -> Doc Source # | |
| PP Kind Source # | |
| PP Literal Source # | |
| PP Pragma Source # | |
| PP UpdHow Source # | |
| PP Error Source # | |
| PP PName Source # | |
| PP Error Source # | |
| PP Position Source # | |
| PP Range Source # | |
| PP Selector Source # | |
| PP Token Source # | |
| PP ConfigLoadError Source # | |
Defined in Cryptol.Project.Config Methods ppPrec :: Int -> ConfigLoadError -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ConfigLoadError -> Doc Source # | |
| PP REPLException Source # | |
Defined in Cryptol.REPL.Monad Methods ppPrec :: Int -> REPLException -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> REPLException -> Doc Source # | |
| PP Smoke Source # | |
| PP CaseAlt Source # | |
| PP Decl Source # | |
| PP DeclGroup Source # | |
| PP Expr Source # | |
| PP Match Source # | |
| PP TCTopEntity Source # | |
Defined in Cryptol.TypeCheck.AST Methods ppPrec :: Int -> TCTopEntity -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> TCTopEntity -> Doc Source # | |
| PP DocFor Source # | |
| PP Error Source # | |
| PP Warning Source # | |
| PP ConstraintSource Source # | |
Defined in Cryptol.TypeCheck.InferTypes Methods ppPrec :: Int -> ConstraintSource -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ConstraintSource -> Doc Source # | |
| PP DerivingConstraintSource Source # | |
Defined in Cryptol.TypeCheck.InferTypes Methods ppPrec :: Int -> DerivingConstraintSource -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> DerivingConstraintSource -> Doc Source # | |
| PP Error Source # | |
| PP Solved Source # | |
| PP Subst Source # | |
| PP Kind Source # | |
| PP PC Source # | |
| PP TC Source # | |
| PP TCon Source # | |
| PP TFun Source # | |
| PP ArgDescr Source # | |
| PP ModParamNames Source # | |
Defined in Cryptol.TypeCheck.Type Methods ppPrec :: Int -> ModParamNames -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModParamNames -> Doc Source # | |
| PP ModTParam Source # | |
| PP ModVParam Source # | |
| PP NominalType Source # | |
Defined in Cryptol.TypeCheck.Type Methods ppPrec :: Int -> NominalType -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> NominalType -> Doc Source # | |
| PP Schema Source # | |
| PP TParam Source # | |
| PP TVar Source # | |
| PP TVarInfo Source # | |
| PP TySyn Source # | |
| PP Type Source # | |
| PP TypeSource Source # | |
Defined in Cryptol.TypeCheck.Type Methods ppPrec :: Int -> TypeSource -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> TypeSource -> Doc Source # | |
| PP Path Source # | |
| PP Assoc Source # | |
| PP Fixity Source # | |
| PP Ident Source # | |
| PP ModName Source # | |
| PP ModPath Source # | |
| PP Namespace Source # | |
| PP OrigName Source # | |
| PP PrimIdent Source # | |
| PP Text Source # | |
| (Show name, PPName name) => PP (Bind name) Source # | |
| (Show name, PPName name) => PP (BindDef name) Source # | |
| (Show name, PPName name) => PP (BindImpl name) Source # | |
| (Show name, PPName name) => PP (CaseAlt name) Source # | |
| (Show name, PPName name) => PP (Decl name) Source # | |
| (Show name, PPName name) => PP (EnumCon name) Source # | |
| (Show name, PPName name) => PP (EnumDecl name) Source # | |
| (Show name, PPName name) => PP (Expr name) Source # | |
| PP name => PP (ImpName name) Source # | |
| PP mname => PP (ImportG mname) Source # | |
| (Show name, PPName name) => PP (Match name) Source # | |
| (Show name, PPName name) => PP (ModParam name) Source # | |
| (Show name, PPName name) => PP (ModuleDefinition name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ModuleDefinition name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleDefinition name -> Doc Source # | |
| (Show name, PPName name) => PP (ModuleInstanceArg name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ModuleInstanceArg name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleInstanceArg name -> Doc Source # | |
| (Show name, PPName name) => PP (ModuleInstanceArgs name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ModuleInstanceArgs name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleInstanceArgs name -> Doc Source # | |
| (Show name, PPName name) => PP (ModuleInstanceNamedArg name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ModuleInstanceNamedArg name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ModuleInstanceNamedArg name -> Doc Source # | |
| (Show name, PPName name) => PP (NestedModule name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> NestedModule name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> NestedModule name -> Doc Source # | |
| PPName name => PP (Newtype name) Source # | |
| (Show name, PPName name) => PP (ParamDecl name) Source # | |
| (Show name, PPName name) => PP (ParameterConstraint name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ParameterConstraint name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ParameterConstraint name -> Doc Source # | |
| (Show name, PPName name) => PP (ParameterFun name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ParameterFun name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ParameterFun name -> Doc Source # | |
| (Show name, PPName name) => PP (ParameterType name) Source # | |
Defined in Cryptol.Parser.AST Methods ppPrec :: Int -> ParameterType name -> Doc Source # ppPrecWithAnnot :: [([Int], PPAnnot)] -> Int -> ParameterType name -> Doc Source # | |
| PPName name => PP (Pattern name) Source # | |
| (Show name, PPName name) => PP (PrimType name) Source # | |
| (Show name, PPName name) => PP (Program name) Source # | |
| PPName name => PP (Prop name) Source # | |
| PPName name => PP (PropSyn name) Source # | |
| PPName name => PP (Schema name) Source # | |
| (Show name, PPName name) => PP (SigDecl name) Source # | |
| PPName name => PP (TParam name) Source # | |
| (Show name, PPName name) => PP (TopDecl name) Source # | |
| PP a => PP (TopLevel a) Source # | |
| PPName name => PP (TySyn name) Source # | |
| PPName name => PP (Type name) Source # | |
| PPName name => PP (TypeInst name) Source # | |
| (Show name, PPName name) => PP (UpdField name) Source # | |
| PP a => PP (Located a) Source # | |
| PP n => PP (ModuleG n) Source # | |
| PP (WithNames Decl) Source # | |
| PP (WithNames DeclDef) Source # | |
| PP (WithNames DeclGroup) Source # | |
| PP (WithNames Expr) Source # | |
| PP (WithNames Match) Source # | |
| PP n => PP (WithNames (ModuleG n)) Source # | |
| PP (WithNames TCTopEntity) Source # | |
Defined in Cryptol.TypeCheck.AST | |
| PP (WithNames Error) Source # | |
| PP (WithNames Warning) Source # | |
| PP (WithNames FFITypeError) Source # | |
Defined in Cryptol.TypeCheck.FFI.Error | |
| PP (WithNames FFITypeErrorReason) Source # | |
Defined in Cryptol.TypeCheck.FFI.Error | |
| PP (WithNames DelayedCt) Source # | |
| PP (WithNames Goal) Source # | |
| PP (WithNames Subst) Source # | |
| PP (WithNames NominalType) Source # | |
Defined in Cryptol.TypeCheck.Type | |
| PP (WithNames Schema) Source # | |
| PP (WithNames TParam) Source # | |
| PP (WithNames TVar) Source # | |
| PP (WithNames TySyn) Source # | |
| PP (WithNames Type) Source # | The precedence levels used by this pretty-printing instance correspond with parser non-terminals as follows:
|
| PPName name => PP [Prop name] Source # | |
| (Show name, PPName mname, PPName name) => PP (ModuleG mname name) Source # | |
class PP a => PPName a where Source #
Methods
ppNameFixity :: a -> Maybe Fixity Source #
Fixity information for infix operators
ppPrefixName :: a -> Doc Source #
Print a name in prefix: f a b or (+) a b)
ppInfixName :: a -> Doc Source #
Print a name as an infix operator: a + b
Information about an infix expression of some sort.
Arguments
| :: (PP thing, PP op) | |
| => Int | Non-infix leaves are printed with this precedence |
| -> (thing -> Maybe (Infix op thing)) | pattern to check if sub-thing is also infix |
| -> Infix op thing | Pretty print this infix expression |
| -> Doc |
Pretty print an infix expression of some sort.
ordinal :: (Integral a, Show a, Eq a) => a -> Doc Source #
Display a numeric value as an ordinal (e.g., 2nd)
ordSuffix :: (Integral a, Eq a) => a -> String Source #
The suffix to use when displaying a number as an oridinal
commaSepFill :: [Doc] -> Doc Source #
Print a comma-separated list. Lay out each item on a single line if it will fit. If an item requires multiple lines, then start it on its own line.