Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Language.Fortran.PrettyPrint
Synopsis
- olderThan :: FortranVersion -> String -> FortranVersion -> a -> a
- continueOnlyFor :: [FortranVersion] -> String -> FortranVersion -> a -> a
- tooOld :: FortranVersion -> String -> FortranVersion -> a
- (<?>) :: Doc -> Doc -> Doc
- (<?+>) :: Doc -> Doc -> Doc
- printMaybe :: (a -> Doc) -> Maybe a -> Doc
- printIndentedBlockWithPre :: FortranVersion -> Indentation -> Doc -> [Block a] -> Doc
- newline :: Doc
- type Indentation = Maybe Int
- incIndentation :: Indentation -> Indentation
- indent :: Indentation -> Doc -> Doc
- overlay :: Doc -> Doc -> Doc
- fixedForm :: Indentation
- pprintAndRender :: IndentablePretty t => FortranVersion -> t -> Indentation -> String
- class IndentablePretty t where
- pprint :: FortranVersion -> t -> Indentation -> Doc
- endGen :: Pretty a => FortranVersion -> Doc -> a -> Indentation -> Doc
- class Pretty t where
- pprint' :: FortranVersion -> t -> Doc
- noParensLit :: FortranVersion -> Expression a -> Doc
- commaSep :: [Doc] -> Doc
- data ReformatState
- reformatMixedFormInsertContinuations :: String -> String
- prettyError :: String -> a
Documentation
olderThan :: FortranVersion -> String -> FortranVersion -> a -> a Source #
Continue only if the given version is equal to or older than a "maximum" version, or emit a runtime error.
continueOnlyFor :: [FortranVersion] -> String -> FortranVersion -> a -> a Source #
Continue if the given version is one of the given "permitted" versions, else emit a runtime error.
tooOld :: FortranVersion -> String -> FortranVersion -> a Source #
Emit a runtime error due to bad pretty printing.
Intended to be used in the otherwise
guard.
printIndentedBlockWithPre :: FortranVersion -> Indentation -> Doc -> [Block a] -> Doc Source #
type Indentation = Maybe Int Source #
pprintAndRender :: IndentablePretty t => FortranVersion -> t -> Indentation -> String Source #
class IndentablePretty t where Source #
Methods
pprint :: FortranVersion -> t -> Indentation -> Doc Source #
Instances
endGen :: Pretty a => FortranVersion -> Doc -> a -> Indentation -> Doc Source #
Methods
pprint' :: FortranVersion -> t -> Doc Source #
Instances
noParensLit :: FortranVersion -> Expression a -> Doc Source #
Pretty print an Expression
inside parentheses, _except_ if the
Expression
is an integer literal, in which case print without the parens.
data ReformatState Source #
Constructors
RefmtStNewline Int | Unsure yet whether current line it's a comment or statement. |
RefmtStComment | Current line is a comment; no need to track column number. |
RefmtStStmt Int | Current line is a statement. |
Instances
Show ReformatState Source # | |
Defined in Language.Fortran.PrettyPrint Methods showsPrec :: Int -> ReformatState -> ShowS # show :: ReformatState -> String # showList :: [ReformatState] -> ShowS # | |
Eq ReformatState Source # | |
Defined in Language.Fortran.PrettyPrint Methods (==) :: ReformatState -> ReformatState -> Bool # (/=) :: ReformatState -> ReformatState -> Bool # | |
Ord ReformatState Source # | |
Defined in Language.Fortran.PrettyPrint Methods compare :: ReformatState -> ReformatState -> Ordering # (<) :: ReformatState -> ReformatState -> Bool # (<=) :: ReformatState -> ReformatState -> Bool # (>) :: ReformatState -> ReformatState -> Bool # (>=) :: ReformatState -> ReformatState -> Bool # max :: ReformatState -> ReformatState -> ReformatState # min :: ReformatState -> ReformatState -> ReformatState # |
reformatMixedFormInsertContinuations :: String -> String Source #
Add continuations where required to a pretty-printed program.
Ensures that no non-comment line exceeds 72 columns.
The reformatting should be compatible with fixed and free-form Fortran
standards, so called intersection
format. In this format the
last statement character should not be placed after column 72, however
continuation character should be put at column 73 (it should be ignored in
fixed-form language)
See: http://fortranwiki.org/fortran/show/Continuation+lines
This is a simple, delicate algorithm that must only be used on pretty printer output, due to relying on particular parser & pretty printer behaviour. In particular, comments not beginning a line (e.g. after a statement or continuation) won't be picked up as a comment, so could wreck that line. Be warned if you're using it on piles of funky-looking code!
prettyError :: String -> a Source #
error
wrapper to make it easier to swap this out for a monad later.