packages feed

compilation 0.0.0.2 → 0.0.0.3

raw patch · 10 files changed

+202/−137 lines, 10 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Compilation: type FreshIndex = Integer
- Control.Compilation: type Indentation = String
- Control.Compilation: type ModuleName = String
- Control.Compilation: type NestingDepth = Integer
- Control.Compilation.Environment: class StateExtension a => Environment a b where addEnv v x = do { s :: a <- get; env :: Env b <- return $ project s; set $ inject ((v, x) : env) s } popEnv = do { s :: a <- get; env :: Env b <- return $ project s; set $ inject (tail env) s } dropEnv n = do { s :: a <- get; env :: Env b <- return $ project s; set $ inject (drop n env) s } lookupEnv v = do { s :: a <- get; env :: Env b <- return $ project s; return $ lookup v env } setEnv env = do { s :: a <- get; set $ inject env s } getEnv = do { s :: a <- get; env :: Env b <- return $ project s; return $ env }
- Control.Compilation.Environment: type Env a = [(String, a)]
- Control.Compilation.Fresh: class StateExtension a => Fresh a where freshInteger = do { s <- get; i <- return $ project s; set $ inject (i + 1) s; return $ i } freshString = do { i <- freshInteger; return $ show i } freshStringWithPrefix prefix = do { s <- freshString; return $ prefix ++ s } freshWithPrefix = freshStringWithPrefix fresh = freshString fresh_ = freshStringWithPrefix freshes i = do { ns <- mapM (\ _ -> fresh) [0 .. i - 1]; return $ [show n | n <- ns] } freshes_ prefix i = do { ns <- mapM (\ _ -> fresh) [0 .. i - 1]; return $ [prefix ++ show n | n <- ns] }
- Control.Compilation.Module: class StateExtension a => Module a where setModule m = do { s <- get; set $ inject m s } getModule = do { s <- get; return $ project s }
- Control.Compilation.Sequence: class StateExtension a => Sequence a b where nest xs = do { s :: a <- get; xss :: [[b]] <- return $ project s; set $ inject (xs : xss) s } unnest = do { s :: a <- get; xs :: [[b]] <- return $ project s; set $ inject (tail $ xs) s; return $ head $ project s } depth = do { s <- get; xss :: [[b]] <- return $ project s; return $ toInteger $ length xss }
- Control.Compilation.Sequence: depth :: Sequence a b => Compilation a Integer
- Control.Compilation.Sequence: inject :: Sequence a b => [[b]] -> a -> a
- Control.Compilation.Sequence: nest :: Sequence a b => [b] -> Compilation a ()
- Control.Compilation.Sequence: project :: Sequence a b => a -> [[b]]
- Control.Compilation.Sequence: unnest :: Sequence a b => Compilation a [b]
+ Control.Compilation.Environment: class StateExtension a => HasEnvironment a b where addEnv v x = do { s :: a <- get; env :: StateExtensionEnv b <- return $ project s; set $ inject ((v, x) : env) s } popEnv = do { s :: a <- get; env :: StateExtensionEnv b <- return $ project s; set $ inject (tail env) s } dropEnv n = do { s :: a <- get; env :: StateExtensionEnv b <- return $ project s; set $ inject (drop n env) s } lookupEnv v = do { s :: a <- get; env :: StateExtensionEnv b <- return $ project s; return $ lookup v env } setEnv env = do { s :: a <- get; set $ inject env s } getEnv = do { s :: a <- get; env :: StateExtensionEnv b <- return $ project s; return $ env }
+ Control.Compilation.Environment: instance StateExtension (StateExtensionEnv a)
+ Control.Compilation.Environment: type StateExtensionEnv a = [(String, a)]
+ Control.Compilation.Fresh: class StateExtension a => HasFresh a where freshInteger = do { s <- get; i <- return $ project s; set $ inject (i + 1) s; return $ i } freshString = do { i <- freshInteger; return $ show i } freshStringWithPrefix prefix = do { s <- freshString; return $ prefix ++ s } freshWithPrefix = freshStringWithPrefix fresh = freshString fresh_ = freshStringWithPrefix freshes i = do { ns <- mapM (\ _ -> fresh) [0 .. i - 1]; return $ [show n | n <- ns] } freshes_ prefix i = do { ns <- mapM (\ _ -> fresh) [0 .. i - 1]; return $ [prefix ++ show n | n <- ns] }
+ Control.Compilation.Fresh: instance StateExtension StateExtensionFresh
+ Control.Compilation.Fresh: type FreshIndex = Integer
+ Control.Compilation.Fresh: type StateExtensionFresh = FreshIndex
+ Control.Compilation.Module: class StateExtension a => HasModule a where setModule m = do { s <- get; set $ inject m s } getModule = do { s <- get; return $ project s }
+ Control.Compilation.Module: type ModuleName = String
+ Control.Compilation.Module: type StateExtensionModule = ModuleName
+ Control.Compilation.Sequences: class StateExtension a => HasSequences a b where nest xs = do { s :: a <- get; xss :: StateExtensionSequences b <- return $ project s; set $ inject (xs : xss) s } unnest = do { s :: a <- get; xs :: StateExtensionSequences b <- return $ project s; set $ inject (tail $ xs) s; return $ head $ project s } depth = do { s <- get; xss :: StateExtensionSequences b <- return $ project s; return $ toInteger $ length xss }
+ Control.Compilation.Sequences: depth :: HasSequences a b => Compilation a Integer
+ Control.Compilation.Sequences: inject :: HasSequences a b => StateExtensionSequences b -> a -> a
+ Control.Compilation.Sequences: instance StateExtension (StateExtensionSequences a)
+ Control.Compilation.Sequences: nest :: HasSequences a b => [b] -> Compilation a ()
+ Control.Compilation.Sequences: project :: HasSequences a b => a -> StateExtensionSequences b
+ Control.Compilation.Sequences: type StateExtensionSequences a = [[a]]
+ Control.Compilation.Sequences: unnest :: HasSequences a b => Compilation a [b]
+ Control.Compilation.String: class StateExtension a => HasString a where indent = do { state <- get; (i, s) <- return $ project state; set $ inject (i + 2, s) state } unindent = do { state <- get; (i, s) <- return $ project state; set $ inject (max 0 (i - 2), s) state } space = do { state <- get; (i, s) <- return $ project state; set $ inject (i, s ++ " ") state } spaces k = do { state <- get; (i, s) <- return $ project state; set $ inject (i, s ++ (take k $ repeat ' ')) state } newline = do { state <- get; (i, s) <- return $ project state; set $ inject (i, s ++ "" ++ (take (fromInteger i) $ repeat ' ')) state } newlines k = do { state <- get; (i, s) <- return $ project state; set $ inject (i, s ++ (take k $ repeat '\n') ++ (take (fromInteger i) $ repeat ' ')) state } string s' = do { state <- get; (i, s) <- return $ project state; set $ inject (i, s ++ s') state } raw = string compiled c = let (_, s) :: StateExtensionString = project (extract c) in s
+ Control.Compilation.String: compiled :: HasString a => Compilation a b -> String
+ Control.Compilation.String: inject :: HasString a => StateExtensionString -> a -> a
+ Control.Compilation.String: instance StateExtension StateExtensionString
+ Control.Compilation.String: project :: HasString a => a -> StateExtensionString
+ Control.Compilation.String: type Indentation = Integer
+ Control.Compilation.String: type StateExtensionString = (Indentation, String)
- Control.Compilation: State :: FreshIndex -> Indentation -> (Maybe ModuleName) -> NestingDepth -> a -> State a
+ Control.Compilation: State :: a -> State a
- Control.Compilation.Environment: addEnv :: Environment a b => String -> b -> Compilation a ()
+ Control.Compilation.Environment: addEnv :: HasEnvironment a b => String -> b -> Compilation a ()
- Control.Compilation.Environment: dropEnv :: Environment a b => Int -> Compilation a ()
+ Control.Compilation.Environment: dropEnv :: HasEnvironment a b => Int -> Compilation a ()
- Control.Compilation.Environment: getEnv :: Environment a b => Compilation a (Env b)
+ Control.Compilation.Environment: getEnv :: HasEnvironment a b => Compilation a (StateExtensionEnv b)
- Control.Compilation.Environment: inject :: Environment a b => Env b -> a -> a
+ Control.Compilation.Environment: inject :: HasEnvironment a b => StateExtensionEnv b -> a -> a
- Control.Compilation.Environment: lookupEnv :: Environment a b => String -> Compilation a (Maybe b)
+ Control.Compilation.Environment: lookupEnv :: HasEnvironment a b => String -> Compilation a (Maybe b)
- Control.Compilation.Environment: popEnv :: Environment a b => Compilation a ()
+ Control.Compilation.Environment: popEnv :: HasEnvironment a b => Compilation a ()
- Control.Compilation.Environment: project :: Environment a b => a -> Env b
+ Control.Compilation.Environment: project :: HasEnvironment a b => a -> StateExtensionEnv b
- Control.Compilation.Environment: setEnv :: Environment a b => Env b -> Compilation a ()
+ Control.Compilation.Environment: setEnv :: HasEnvironment a b => StateExtensionEnv b -> Compilation a ()
- Control.Compilation.Fresh: fresh :: Fresh a => Compilation a String
+ Control.Compilation.Fresh: fresh :: HasFresh a => Compilation a String
- Control.Compilation.Fresh: freshInteger :: Fresh a => Compilation a Integer
+ Control.Compilation.Fresh: freshInteger :: HasFresh a => Compilation a Integer
- Control.Compilation.Fresh: freshString :: Fresh a => Compilation a String
+ Control.Compilation.Fresh: freshString :: HasFresh a => Compilation a String
- Control.Compilation.Fresh: freshStringWithPrefix :: Fresh a => String -> Compilation a String
+ Control.Compilation.Fresh: freshStringWithPrefix :: HasFresh a => String -> Compilation a String
- Control.Compilation.Fresh: freshWithPrefix :: Fresh a => String -> Compilation a String
+ Control.Compilation.Fresh: freshWithPrefix :: HasFresh a => String -> Compilation a String
- Control.Compilation.Fresh: fresh_ :: Fresh a => String -> Compilation a String
+ Control.Compilation.Fresh: fresh_ :: HasFresh a => String -> Compilation a String
- Control.Compilation.Fresh: freshes :: Fresh a => Integer -> Compilation a [String]
+ Control.Compilation.Fresh: freshes :: HasFresh a => Integer -> Compilation a [String]
- Control.Compilation.Fresh: freshes_ :: Fresh a => String -> Integer -> Compilation a [String]
+ Control.Compilation.Fresh: freshes_ :: HasFresh a => String -> Integer -> Compilation a [String]
- Control.Compilation.Fresh: inject :: Fresh a => Integer -> a -> a
+ Control.Compilation.Fresh: inject :: HasFresh a => StateExtensionFresh -> a -> a
- Control.Compilation.Fresh: project :: Fresh a => a -> Integer
+ Control.Compilation.Fresh: project :: HasFresh a => a -> StateExtensionFresh
- Control.Compilation.Module: getModule :: Module a => Compilation a String
+ Control.Compilation.Module: getModule :: HasModule a => Compilation a String
- Control.Compilation.Module: inject :: Module a => String -> a -> a
+ Control.Compilation.Module: inject :: HasModule a => StateExtensionModule -> a -> a
- Control.Compilation.Module: project :: Module a => a -> String
+ Control.Compilation.Module: project :: HasModule a => a -> StateExtensionModule
- Control.Compilation.Module: setModule :: Module a => String -> Compilation a ()
+ Control.Compilation.Module: setModule :: HasModule a => String -> Compilation a ()
- Control.Compilation.String: indent :: Compilation String ()
+ Control.Compilation.String: indent :: HasString a => Compilation a ()
- Control.Compilation.String: newline :: Compilation String ()
+ Control.Compilation.String: newline :: HasString a => Compilation a ()
- Control.Compilation.String: newlines :: Int -> Compilation String ()
+ Control.Compilation.String: newlines :: HasString a => Int -> Compilation a ()
- Control.Compilation.String: raw :: String -> Compilation String ()
+ Control.Compilation.String: raw :: HasString a => String -> Compilation a ()
- Control.Compilation.String: space :: Compilation String ()
+ Control.Compilation.String: space :: HasString a => Compilation a ()
- Control.Compilation.String: spaces :: Int -> Compilation String ()
+ Control.Compilation.String: spaces :: HasString a => Int -> Compilation a ()
- Control.Compilation.String: string :: String -> Compilation String ()
+ Control.Compilation.String: string :: HasString a => String -> Compilation a ()
- Control.Compilation.String: unindent :: Compilation String ()
+ Control.Compilation.String: unindent :: HasString a => Compilation a ()

Files

Control/Compilation.hs view
@@ -19,22 +19,13 @@ ----------------------------------------------------------------
 -- | Data types, class declarations, and class memberships.
 
-type FreshIndex = Integer
-type Indentation = String
-type ModuleName = String
-type NestingDepth = Integer
-
-data State a =
-  State
-    FreshIndex
-    Indentation
-    (Maybe ModuleName)
-    NestingDepth
-    a     -- State data structure.
-
 class StateExtension a where
   initial :: a
 
+-- | State data structure wrapper.
+data State a =
+  State a
+  
 type Compile a b = Compilation a b
 data Compilation a b = 
     Compilation (State a -> (State a, b))
@@ -63,19 +54,19 @@ -- | Generic combinators and functions.
 
 extract :: StateExtension a => Compilation a b -> a
-extract (Compilation c) = let (State _ _ _ _ r, _) = c (State 0 "" Nothing 0 initial) in r
+extract (Compilation c) = let (State e, _) = c (State initial) in e
 
 extractFromState :: StateExtension a => a -> Compilation a b -> a
-extractFromState s (Compilation c) = let (State _ _ _ _ r, _) = c (State 0 "" Nothing 0 s) in r
+extractFromState s (Compilation c) = let (State e, _) = c (State s) in e
 
 nothing :: Compilation a ()
 nothing = Compilation $ \s -> (s, ())
 
 get :: StateExtension a => Compilation a a
-get = Compilation $ \(State f i m n s) -> (State f i m n s, s)
+get = Compilation $ \(State e) -> (State e, e)
 
 set :: StateExtension a => a -> Compilation a ()
-set s = Compilation $ \(State f i m n _) -> (State f i m n s, ())
+set e = Compilation $ \(State _) -> (State e, ())
 
 error :: String -> Compilation a ()
 error err = Error err
Control/Compilation/Environment.hs view
@@ -15,6 +15,7 @@ --
 
 {-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables #-}
+{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
 
 module Control.Compilation.Environment
   where
@@ -22,50 +23,53 @@ import Control.Compilation
 
 ----------------------------------------------------------------
--- | Type synonyms.
+-- | Type synonyms and class memberships.
 
-type Env a = [(String, a)]
+type StateExtensionEnv a = [(String, a)]
 
+instance StateExtension (StateExtensionEnv a) where
+  initial = []
+
 ----------------------------------------------------------------
 -- | State extension class definition.
 
-class StateExtension a => Environment a b where
-  project :: a -> Env b
-  inject :: Env b -> a -> a
+class StateExtension a => HasEnvironment a b where
+  project :: a -> StateExtensionEnv b
+  inject :: StateExtensionEnv b -> a -> a
 
   addEnv :: String -> b -> Compilation a ()
   addEnv v x =
     do s :: a <- get
-       env :: Env b <- return $ project s
+       env :: StateExtensionEnv b <- return $ project s
        set $ inject ((v,x):env) s
 
   popEnv :: Compilation a ()
   popEnv =
     do s :: a <- get
-       env :: Env b <- return $ project s
+       env :: StateExtensionEnv b <- return $ project s
        set $ inject (tail env) s
 
   dropEnv :: Int -> Compilation a ()
   dropEnv n =
     do s :: a <- get
-       env :: Env b <- return $ project s
+       env :: StateExtensionEnv b <- return $ project s
        set $ inject (drop n env) s
 
   lookupEnv :: String -> Compilation a (Maybe b)
   lookupEnv v =
     do s :: a <- get
-       env :: Env b <- return $ project s
+       env :: StateExtensionEnv b <- return $ project s
        return $ lookup v env
 
-  setEnv :: Env b -> Compilation a ()
+  setEnv :: StateExtensionEnv b -> Compilation a ()
   setEnv env =
     do s :: a <- get
        set $ inject env s
 
-  getEnv :: Compilation a (Env b)
+  getEnv :: Compilation a (StateExtensionEnv b)
   getEnv =
     do s :: a <- get
-       env :: Env b <- return $ project s
+       env :: StateExtensionEnv b <- return $ project s
        return $ env
 
 --eof
Control/Compilation/Fresh.hs view
@@ -14,18 +14,29 @@ ----------------------------------------------------------------
 --
 
+{-# LANGUAGE TypeSynonymInstances #-}
+
 module Control.Compilation.Fresh
   where
 
 import Control.Compilation
 
 ----------------------------------------------------------------
+-- | Type synonyms and class memberships.
+
+type FreshIndex = Integer
+type StateExtensionFresh = FreshIndex
+
+instance StateExtension StateExtensionFresh where
+  initial = 0
+
+----------------------------------------------------------------
 -- | State extension class definition, including combinators
 --   and convenient synonyms.
 
-class StateExtension a => Fresh a where
-  project :: a -> Integer
-  inject :: Integer -> a -> a
+class StateExtension a => HasFresh a where
+  project :: a -> StateExtensionFresh
+  inject :: StateExtensionFresh -> a -> a
 
   freshInteger :: Compilation a Integer
   freshInteger =
@@ -62,5 +73,5 @@   freshes_ prefix i =
     do ns <- mapM (\_ -> fresh) [0..i-1]
        return $ [prefix ++ show n | n <- ns]
-
+       
 --eof
Control/Compilation/Module.hs view
@@ -13,17 +13,25 @@ ----------------------------------------------------------------
 --
 
+{-# LANGUAGE TypeSynonymInstances #-}
+
 module Control.Compilation.Module
   where
 
 import Control.Compilation
 
 ----------------------------------------------------------------
+-- | Type synonyms and class memberships.
+
+type ModuleName = String
+type StateExtensionModule = ModuleName
+
+----------------------------------------------------------------
 -- | State extension class definition, including combinators.
 
-class StateExtension a => Module a where
-  project :: a -> String
-  inject :: String -> a -> a
+class StateExtension a => HasModule a where
+  project :: a -> StateExtensionModule
+  inject :: StateExtensionModule -> a -> a
 
   setModule :: String -> Compilation a ()
   setModule m =
− Control/Compilation/Sequence.hs
@@ -1,53 +0,0 @@-----------------------------------------------------------------
---
--- | Compilation
---   Monad and combinators for quickly assembling simple
---   compilers.
---
--- @Control\/Compilation\/Sequence.hs@
---
---   A generic compilation monad for quickly assembling simple
---   compilers for target languages that are primarily
---   sequences of instructions (possibly with nesting, e.g., 
---   loop constructs or procedures).
---
-
-----------------------------------------------------------------
---
-
-{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables #-}
-
-module Control.Compilation.Sequence
-  where
-
-import Control.Compilation
-
-----------------------------------------------------------------
--- | State extension class definition, and combinators for
---   compiling into a sequence (possibly with nested blocks)
---   of instructions.
-
-class StateExtension a => Sequence a b where
-  project :: a -> [[b]]
-  inject :: [[b]] -> a -> a
-
-  nest :: [b] -> Compilation a ()
-  nest xs =
-    do s :: a <- get
-       xss :: [[b]] <- return $ project s
-       set $ inject (xs : xss) s
-
-  unnest :: Compilation a [b]
-  unnest =
-    do s :: a <- get
-       xs :: [[b]] <- return $ project s
-       set $ inject (tail $ xs) s
-       return $ head $ project s
-
-  depth :: Compilation a Integer
-  depth =
-    do s <- get
-       xss :: [[b]] <- return $ project s
-       return $ toInteger $ length xss
-
---eof
+ Control/Compilation/Sequences.hs view
@@ -0,0 +1,62 @@+----------------------------------------------------------------
+--
+-- | Compilation
+--   Monad and combinators for quickly assembling simple
+--   compilers.
+--
+-- @Control\/Compilation\/Sequences.hs@
+--
+--   A generic compilation monad for quickly assembling simple
+--   compilers for target languages that are primarily
+--   sequences of instructions (possibly with nesting, e.g., 
+--   loop constructs or procedures).
+--
+
+----------------------------------------------------------------
+--
+
+{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables #-}
+{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
+
+module Control.Compilation.Sequences
+  where
+
+import Control.Compilation
+
+----------------------------------------------------------------
+-- | Type synonyms and class memberships.
+
+type StateExtensionSequences a = [[a]]
+
+instance StateExtension (StateExtensionSequences a) where
+  initial = []
+
+----------------------------------------------------------------
+-- | State extension class definition, and combinators for
+--   compiling into a sequence (possibly with nested blocks)
+--   of instructions.
+
+class StateExtension a => HasSequences a b where
+  project :: a -> StateExtensionSequences b
+  inject :: StateExtensionSequences b -> a -> a
+
+  nest :: [b] -> Compilation a ()
+  nest xs =
+    do s :: a <- get
+       xss :: StateExtensionSequences b <- return $ project s
+       set $ inject (xs : xss) s
+
+  unnest :: Compilation a [b]
+  unnest =
+    do s :: a <- get
+       xs :: StateExtensionSequences b <- return $ project s
+       set $ inject (tail $ xs) s
+       return $ head $ project s
+
+  depth :: Compilation a Integer
+  depth =
+    do s <- get
+       xss :: StateExtensionSequences b <- return $ project s
+       return $ toInteger $ length xss
+
+--eof
Control/Compilation/String.hs view
@@ -15,37 +15,78 @@ ----------------------------------------------------------------
 --
 
+{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+
 module Control.Compilation.String
   where
   
 import Control.Compilation
 
 ----------------------------------------------------------------
--- | Combinators and functions for compiling directly into a raw
---   ASCII string.
+-- | Type synonyms and class memberships.
 
-indent :: Compilation String ()
-indent = Compilation $ \(State f i m n s) -> (State f ("  " ++ i) m n s, ())
+type Indentation = Integer
+type StateExtensionString = (Indentation, String)
 
-unindent :: Compilation String ()
-unindent = Compilation $ \(State f i m n s) -> (State f (drop (min (length i) 2) i) m n s, ())
+instance StateExtension StateExtensionString where
+  initial = (0, "")
 
-space :: Compilation String ()
-space = Compilation $ \(State f i m n s) -> (State f i m n (s ++ " "), ())
+----------------------------------------------------------------
+-- | State extension class definition, including combinators
+--   and convenient synonyms for compiling directly into a raw
+--   ASCII string.
 
-spaces :: Int -> Compilation String ()
-spaces k = Compilation $ \(State f i m n s) -> (State f i m n (s ++ (take k $ repeat ' ')), ())
+class StateExtension a => HasString a where
+  project :: a -> StateExtensionString
+  inject :: StateExtensionString -> a -> a
+  
+  indent :: Compilation a ()
+  indent =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i + 2, s) state
 
-newline :: Compilation String ()
-newline = Compilation $ \(State f i m n s) -> (State f i m n (s ++ "\n" ++ i), ())
+  unindent :: Compilation a ()
+  unindent =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (max 0 (i - 2), s) state
+   
+  space :: Compilation a ()
+  space =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i, s ++ " ") state
 
-newlines :: Int -> Compilation String ()
-newlines k = Compilation $ \(State f i m n s) -> (State f i m n (s ++ (take k $ repeat '\n') ++ i), ())
+  spaces :: Int -> Compilation a ()
+  spaces k =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i, s ++ (take k $ repeat ' ')) state
 
-string :: String -> Compilation String ()
-string s' = Compilation $ \(State f i m n s) -> (State f i m n (s ++ s'), ())
+  newline :: Compilation a ()
+  newline =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i, s ++ "\n" ++ (take (fromInteger i) $ repeat ' ')) state
 
-raw :: String -> Compilation String ()
-raw = string
+  newlines :: Int -> Compilation a ()
+  newlines k =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i, s ++ (take k $ repeat '\n') ++ (take (fromInteger i) $ repeat ' ')) state
+
+  string :: String -> Compilation a ()
+  string s' =
+    do state <- get
+       (i, s) <- return $ project state
+       set $ inject (i, s ++ s') state
+
+  raw :: String -> Compilation a ()
+  raw = string
+  
+  compiled :: Compilation a b -> String
+  compiled c = let (_, s) :: StateExtensionString = project (extract c) in s
 
 --eof
− Control/Compilation/Tree.hs
@@ -1,27 +0,0 @@-----------------------------------------------------------------
---
--- | Compilation
---   Monad and combinators for quickly assembling simple
---   compilers.
---
--- @Control\/Compilation\/Tree.hs@
---
---   A generic compilation monad for quickly assembling simple
---   compilers for target languages that are primarily
---   expression trees.
---
-
-----------------------------------------------------------------
---
-
-module Control.Compilation.Tree
-  where
-
-import Control.Compilation
-
-----------------------------------------------------------------
--- Combinator definitions.
-
-() = ()
-
---eof
+ Control/Compilation/Trees.hs view
@@ -0,0 +1,28 @@+----------------------------------------------------------------
+--
+-- | Compilation
+--   Monad and combinators for quickly assembling simple
+--   compilers.
+--
+-- @Control\/Compilation\/Trees.hs@
+--
+--   A generic compilation monad for quickly assembling simple
+--   compilers for target languages that are primarily
+--   expression trees.
+--
+
+----------------------------------------------------------------
+--
+
+module Control.Compilation.Trees
+  where
+
+import Control.Compilation
+
+----------------------------------------------------------------
+-- | State extension class definition, including combinators
+--   and convenient synonyms.
+
+() = ()
+
+--eof
compilation.cabal view
@@ -1,5 +1,5 @@ Name:              compilation
-Version:           0.0.0.2
+Version:           0.0.0.3
 Cabal-Version:     >= 1.6
 License:           GPL-3
 License-File:      LICENSE
@@ -16,8 +16,8 @@                    Control.Compilation.Module,
                    Control.Compilation.Environment,
                    Control.Compilation.String,
-                   Control.Compilation.Sequence,
-                   Control.Compilation.Tree
+                   Control.Compilation.Sequences,
+                   Control.Compilation.Trees
   Build-Depends:   base >= 3 && < 5, MissingH
 
 Source-Repository head