License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Pretty-printing for the Swarm language.
Synopsis
- class PrettyPrec a where
- prettyPrec :: Int -> a -> Doc ann
- ppr :: PrettyPrec a => a -> Doc ann
- docToText :: Doc a -> Text
- prettyText :: PrettyPrec a => a -> Text
- prettyTextLine :: PrettyPrec a => a -> Text
- docToString :: Doc a -> String
- prettyString :: PrettyPrec a => a -> String
- pparens :: Bool -> Doc ann -> Doc ann
- encloseWithIndent :: Int -> Doc ann -> Doc ann -> Doc ann -> Doc ann
- bquote :: Doc ann -> Doc ann
- prettyShowLow :: Show a => a -> Doc ann
- data Prec a = Prec Int a
- data BulletList i = BulletList {
- bulletListHeader :: forall a. Doc a
- bulletListItems :: [i]
- data Wildcard = Wildcard
- class UnchainableFun t where
- unchainFun :: t -> [t]
- prettyBinding :: (Pretty a, PrettyPrec b) => (a, b) -> Doc ann
- prettyEquality :: (Pretty a, PrettyPrec b) => (a, Maybe b) -> Doc ann
- prettyTuple :: Term -> Doc a
- prettyDefinition :: Doc ann -> Var -> Maybe Polytype -> Term -> Doc ann
- prettyPrecApp :: Int -> Term -> Term -> Doc a
- appliedTermPrec :: Term -> Int
- prettyLambdas :: Term -> Doc a
- unchainLambdas :: Term -> (Term, [(Var, Maybe Type)])
- prettyLambda :: (Pretty a1, PrettyPrec a2) => (a1, Maybe a2) -> Doc ann
- prettyTypeErrText :: Text -> ContextualTypeErr -> Text
- prettyTypeErr :: Text -> ContextualTypeErr -> Doc ann
- typeDescription :: Source -> UType -> Doc a
- hasAnyUVars :: UType -> Bool
- isTopLevelConstructor :: UType -> Maybe (TypeF ())
- tyNounPhrase :: TypeF () -> Doc a
- baseTyNounPhrase :: BaseTy -> Doc a
- fieldMismatchMsg :: Set Var -> Set Var -> Doc a
Documentation
class PrettyPrec a where Source #
Type class for things that can be pretty-printed, given a precedence level of their context.
prettyPrec :: Int -> a -> Doc ann Source #
Instances
ppr :: PrettyPrec a => a -> Doc ann Source #
Pretty-print a thing, with a context precedence level of zero.
prettyText :: PrettyPrec a => a -> Text Source #
Pretty-print something and render it as Text
.
prettyTextLine :: PrettyPrec a => a -> Text Source #
Pretty-print something and render it as (preferably) one line Text
.
docToString :: Doc a -> String Source #
Render a pretty-printed document as a String
.
prettyString :: PrettyPrec a => a -> String Source #
Pretty-print something and render it as a String
.
pparens :: Bool -> Doc ann -> Doc ann Source #
Optionally surround a document with parentheses depending on the
Bool
argument and if it does not fit on line, indent the lines,
with the parens on separate lines.
prettyShowLow :: Show a => a -> Doc ann Source #
Turn a Show
instance into a Doc
, lowercasing it in the
process.
data BulletList i Source #
BulletList | |
|
Instances
PrettyPrec i => PrettyPrec (BulletList i) Source # | |
Defined in Swarm.Language.Pretty prettyPrec :: Int -> BulletList i -> Doc ann Source # |
We can use the Wildcard
value to replace unification variables
when we don't care about them, e.g. to print out the shape of a
type like (_ -> _) * _
class UnchainableFun t where Source #
Split a function type chain, so that we can pretty print the type parameters aligned on each line when they don't fit.
unchainFun :: t -> [t] Source #
Instances
UnchainableFun Type Source # | |
Defined in Swarm.Language.Pretty unchainFun :: Type -> [Type] Source # | |
UnchainableFun (UTerm TypeF ty) Source # | |
Defined in Swarm.Language.Pretty |
prettyBinding :: (Pretty a, PrettyPrec b) => (a, b) -> Doc ann Source #
prettyEquality :: (Pretty a, PrettyPrec b) => (a, Maybe b) -> Doc ann Source #
prettyTuple :: Term -> Doc a Source #
appliedTermPrec :: Term -> Int Source #
prettyLambdas :: Term -> Doc a Source #
prettyLambda :: (Pretty a1, PrettyPrec a2) => (a1, Maybe a2) -> Doc ann Source #
prettyTypeErrText :: Text -> ContextualTypeErr -> Text Source #
Format a ContextualTypeError
for the user and render it as
Text
.
prettyTypeErr :: Text -> ContextualTypeErr -> Doc ann Source #
Format a ContextualTypeError
for the user.
typeDescription :: Source -> UType -> Doc a Source #
Given a type and its source, construct an appropriate description of it to go in a type mismatch error message.
hasAnyUVars :: UType -> Bool Source #
Check whether a type contains any unification variables at all.
isTopLevelConstructor :: UType -> Maybe (TypeF ()) Source #
Check whether a type consists of a top-level type constructor immediately applied to unification variables.
tyNounPhrase :: TypeF () -> Doc a Source #
Return an English noun phrase describing things with the given top-level type constructor.
baseTyNounPhrase :: BaseTy -> Doc a Source #
Return an English noun phrase describing things with the given base type.