hpp-0.1.0.0: A Haskell pre-processor

Safe HaskellSafe
LanguageHaskell2010

Hpp.Types

Contents

Description

The core types involved used by the pre-processor.

Synopsis

Documentation

type LineNum = Int Source

Line numbers are represented as Ints

Errors

Pre-processor Actions

data Hpp a Source

A free monad construction to strictly delimit what capabilities we need to perform pre-processing.

newtype ErrHpp a Source

An Hpp action that can fail.

Constructors

ErrHpp 

Fields

runErrHpp :: Hpp (Either (FilePath, Error) a)
 

Expansion

data Scan Source

Macro expansion involves treating tokens differently if they appear in the original source for or as the result of a previous macro expansion. This distinction is used to prevent divergence by masking out definitions that could be used recursively.

Things are made somewhat more complicated than one might expect due to the fact that the scope of this masking is not structurally recursive. A object-like macro can expand into a fragment of a macro function application, one of whose arguments is a token matching the original object-like macro. That argument should not be expanded.

Instances

type DList a = [a] -> [a] Source

A difference list is a list representation with O(1) snoc'ing at the end of the list.

Macros

data Macro Source

There are object-like macros and function-like macros.

Constructors

Object [Token]

An object-like macro is replaced with its definition

Function Int ([([Scan], String)] -> [Scan])

A function-like macro of some arity taks macro-expanded and raw versions of its arguments, then substitutes them into a body producing a new set of tokens.

Instances