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

Safe HaskellSafe
LanguageHaskell98

Code.Build

Contents

Synopsis

Documentation

newtype Code #

Representation of code, each string represents a line

Constructors

Code 

Fields

Instances

Codeable Code # 

Methods

code :: Code -> Code #

class Codeable a where #

Type class for lifting data structures into code

Minimal complete definition

code

Methods

code :: a -> Code #

Instances

Show a => Codeable a # 

Methods

code :: a -> Code #

Codeable String # 

Methods

code :: String -> Code #

Codeable Code # 

Methods

code :: Code -> Code #

Codeable a => Codeable (Maybe a) # 

Methods

code :: Maybe a -> Code #

class CodeList a where #

Minimal complete definition

codeList

Methods

codeList :: a -> [Code] #

Instances

Codeable a => CodeList a # 

Methods

codeList :: a -> [Code] #

Codeable a => CodeList [a] # 

Methods

codeList :: [a] -> [Code] #

Functions on code

isNull :: Codeable a => a -> Bool #

numLines :: CodeList a => a -> Int #

singleLine :: CodeList a => a -> Bool #

indent :: Codeable a => Int -> a -> Code #

surround :: Codeable a => String -> String -> a -> Code #

parenthesis :: Codeable a => a -> Code #

accolades :: Codeable a => a -> Code #

square :: Codeable a => a -> Code #

align :: Codeable a => a -> Code #

codeWidth :: Codeable a => a -> Int #

codeLines :: Codeable a => a -> [Code] #

many :: Codeable a => a -> Code #

mkSequence :: Codeable a => [a] -> Code #

mkStack :: Codeable a => [a] -> Code #

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

Combinators for building blocks of code

(|><|) :: (Codeable a, Codeable b) => a -> b -> Code infixl 3 #

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 -> Code infixl 3 #

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

(|><) :: (Codeable a, Codeable b) => a -> b -> Code infixl 3 #

Left outer-join

(><|) :: (Codeable a, Codeable b) => a -> b -> Code infixl 3 #

Right outer-join

(<+>) :: (Codeable a, Codeable b) => a -> b -> Code infixl 4 #

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

(<++>) :: (Codeable a, Codeable b) => a -> b -> Code infixl 4 #

Same as ++ but with space

(<+|) :: (Codeable a, Codeable b) => a -> b -> Code infixl 4 #

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

(|>+<|) :: (Codeable a, CodeList b) => a -> b -> Code infixl 3 #

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

(<->) :: (Codeable a, Codeable b) => a -> b -> Code infixl 2 #

Place two pieces of code under each other