hindent-5.3.4: Extensible Haskell pretty printer

Safe Haskell | Safe-Inferred
Language | Haskell2010

HIndent.CodeBlock

Synopsis

- data CodeBlock
  - = Shebang ByteString
  - | HaskellSource Int ByteString
  - | CPPDirectives ByteString
- cppSplitBlocks :: ByteString -> [CodeBlock]

# Documentation

data CodeBlock Source #

A block of code.

Constructors

Shebang ByteString |
HaskellSource Int ByteString | Includes the starting line (indexed from 0) for error reporting
CPPDirectives ByteString |

#### Instances

Instances details

Show CodeBlock Source # |
Instance details Defined in HIndent.CodeBlock Methods showsPrec :: Int -> CodeBlock -> ShowS Source # show :: CodeBlock -> String Source # showList :: [CodeBlock] -> ShowS Source #
Eq CodeBlock Source # |
Instance details Defined in HIndent.CodeBlock Methods (==) :: CodeBlock -> CodeBlock -> Bool Source # (/=) :: CodeBlock -> CodeBlock -> Bool Source #

cppSplitBlocks :: ByteString -> [CodeBlock] Source #

Break a Haskell code string into chunks, using CPP as a delimiter. Lines that start with '#if', '#end', or '#else' are their own chunks, and also act as chunk separators. For example, the code

    #ifdef X
    x = X
    y = Y
    #else
    x = Y
    y = X
    #endif

will become five blocks, one for each CPP line and one for each pair of declarations.