code-builder-0.1.3: Simple system for generating code.

Safe HaskellNone

Code.Build

Contents

Synopsis

Documentation

newtype Code Source

Representation of code, each string represents a line

Constructors

Code 

Fields

unCode :: [String]
 

Instances

class Codeable a whereSource

Type class for lifting data structures into code

Methods

code :: a -> CodeSource

class CodeList a whereSource

Methods

codeList :: a -> [Code]Source

Instances

Codeable a => CodeList a 
Codeable a => CodeList [a] 

Functions on code

indent :: Codeable a => Int -> a -> CodeSource

many :: Codeable a => a -> CodeSource

mkStack :: Codeable a => [a] -> CodeSource

interleave :: (Codeable a, CodeList l) => a -> l -> CodeSource

Combinators for building blocks of code

(|><|) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Join two blocks line by line, in the way of inner join, so both lines have to be present.

(><) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Join two blocks line by line, in the way of outer join, so both missing lines are discarded.

(|><) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Left outer-join

(><|) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Right outer-join

(<+>) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Sequencing. Place the second block after the last line of the first block. Aligns the second block

(<++>) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Same as ++ but with space

(<+|) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Place the second block after the last line of the first block. Aligns the second block

(|>+<|) :: (Codeable a, CodeList b) => a -> b -> CodeSource

Combination of join and sequence. The code blocks in the second argument are sequenced with the first argument.

(<->) :: (Codeable a, Codeable b) => a -> b -> CodeSource

Place two pieces of code under each other