<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>cspm/src/HST/CSPM/Environments.hs</filename>
    </added>
    <added>
      <filename>cspm/tests/HST/CSPM/Tests/Environments.hs</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -8,9 +8,11 @@ Author:          Douglas Creager
 
 Library
   HS-Source-Dirs:  src, tests
-  Build-Depends:    base, haskell98, QuickCheck &gt;= 1.1
+  Build-Depends:    base, haskell98, containers,
+                    QuickCheck &gt;= 1.1
   Exposed-Modules:  HST.CSPM
-  Other-Modules:    HST.CSPM.Evaluate,
+  Other-Modules:    HST.CSPM.Environments,
+                    HST.CSPM.Evaluate,
                     HST.CSPM.Expressions,
                     HST.CSPM.Values
 </diff>
      <filename>cspm/HST.cabal</filename>
    </modified>
    <modified>
      <diff>@@ -24,10 +24,12 @@ module HST.CSPM
     (
      module HST.CSPM.Expressions,
      module HST.CSPM.Values,
-     module HST.CSPM.Evaluate
+     module HST.CSPM.Evaluate,
+     module HST.CSPM.Environments
     )
     where
 
 import HST.CSPM.Expressions
 import HST.CSPM.Values
 import HST.CSPM.Evaluate
+import HST.CSPM.Environments</diff>
      <filename>cspm/src/HST/CSPM.hs</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,7 @@ import HST.CSPM.Values
 
 eval :: Expression -&gt; Value
 
+eval EBottom             = VBottom
 eval (ENumber id)        = VNumber (evalNumber id)
 eval (ESequence s)       = VSequence (evalSequence s)
 eval (ESet a)            = VSet (evalSet a)</diff>
      <filename>cspm/src/HST/CSPM/Evaluate.hs</filename>
    </modified>
    <modified>
      <diff>@@ -22,18 +22,37 @@
 
 module HST.CSPM.Expressions where
 
+-- Identifiers
+
+newtype Identifier
+    = Identifier String
+    deriving (Eq, Ord)
+
+instance Show Identifier where
+    show (Identifier s) = show s
+
+data Binding
+    = Binding Identifier Expression
+    deriving (Eq, Ord)
+
+instance Show Binding where
+    show (Binding id x) = show id ++ &quot; = &quot; ++ show x
+
 -- Expressions
 
 data Expression
-    = ENumber Number
+    = EBottom
+    | ENumber Number
     | ESequence Sequence
     | ESet Set
     | EBoolean Boolean
     | ETuple Tuple
     | QHead Expression
     | EIfThenElse Expression Expression Expression
+    deriving (Eq, Ord)
 
 instance Show Expression where
+    show EBottom = &quot;Bottom&quot;
     show (ENumber n) = show n
     show (ESequence s) = show s
     show (ESet a) = show a
@@ -66,6 +85,7 @@ data Number
     | NRem Expression Expression
     | QLength Expression
     | SCardinality Expression
+    deriving (Eq, Ord)
 
 instance Show Number where
     show (NLit i)         = show i
@@ -87,6 +107,7 @@ data Sequence
     | QConcat Expression Expression
     | QTail Expression
     -- TODO: sequence comprehension
+    deriving (Eq, Ord)
 
 instance Show Sequence where
     show (QLit xs)          = &quot;&lt;&quot; ++ show xs ++ &quot;&gt;&quot;
@@ -110,6 +131,7 @@ data Set
     | SPowerset Expression
     | SSequenceset Expression
     -- TODO: set comprehension
+    deriving (Eq, Ord)
 
 instance Show Set where
     show (SLit xs)              = &quot;{&quot; ++ show xs ++ &quot;}&quot;
@@ -142,6 +164,7 @@ data Boolean
     | QIn Expression Expression
     | SIn Expression Expression
     | SEmpty Expression
+    deriving (Eq, Ord)
 
 instance Show Boolean where
     show BTrue             = &quot;true&quot;
@@ -164,4 +187,4 @@ instance Show Boolean where
 
 data Tuple
     = TLit [Expression]
-    deriving Show
+    deriving (Eq, Ord, Show)</diff>
      <filename>cspm/src/HST/CSPM/Expressions.hs</filename>
    </modified>
    <modified>
      <diff>@@ -53,7 +53,8 @@ listOf g = sized listOf'
     where
       listOf' n = sequence [g | i &lt;- [1..n]]
 
-esequence = listOf enumber
+qsequence = listOf enumber
+esequence = liftM (ESequence . QLit) qsequence
 
 boolean :: Gen Boolean
 boolean = sized boolean'
@@ -67,3 +68,10 @@ boolean = sized boolean'
                    subbool = liftM EBoolean $ boolean' (n `div` 2)
 
 eboolean = liftM EBoolean boolean
+
+expression = oneof [enumber, esequence, eboolean]
+
+identifier = elements $ map (Identifier . (:[])) ['a'..'z']
+
+pair :: Gen a -&gt; Gen b -&gt; Gen (a, b)
+pair = liftM2 (curry id)</diff>
      <filename>cspm/tests/HST/CSPM/Tests/Generators.hs</filename>
    </modified>
    <modified>
      <diff>@@ -58,7 +58,7 @@ prop_SeqClosedRange = forAll (two enumber) tester
             VNumber i1 = eval n1
             VNumber i2 = eval n2
 
-prop_SeqConcat = forAll (two esequence) tester
+prop_SeqConcat = forAll (two qsequence) tester
     where
       tester (ns1, ns2) = v0 == v12
           where
@@ -71,7 +71,7 @@ prop_SeqConcat = forAll (two esequence) tester
             VSequence q2 = v2
             v12 = VSequence (q1 ++ q2)
 
-prop_SeqTail = forAll esequence tester
+prop_SeqTail = forAll qsequence tester
     where
       tester ns = (length ns &gt; 0) ==&gt; v0 == v1
           where</diff>
      <filename>cspm/tests/HST/CSPM/Tests/Sequences.hs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>eefa050ea24b224a956ca442752678d9a23c441c</id>
    </parent>
  </parents>
  <author>
    <name>Douglas Creager</name>
    <email>dcreager@alum.mit.edu</email>
  </author>
  <url>http://github.com/dcreager/hst/commit/2a3f31e387e7b41c1856ff79a47ad5bfebdea5cc</url>
  <id>2a3f31e387e7b41c1856ff79a47ad5bfebdea5cc</id>
  <committed-date>2008-08-30T13:42:50-07:00</committed-date>
  <authored-date>2008-08-30T13:04:21-07:00</authored-date>
  <message>CSPM environments

An environment is the symbol table that hold CSPM definitions.  They
provide a standard mapping between identifiers and the expressions
that define them.  Environments can also have an optional parent,
which allows nested scoping; if an identifier is not found in the
current environment, we then proceed to look for it in the containing
environment.

This patch introduces the basic API for creating and using
environments, but does not extend the evaluation rules to use them.

Lighthouse: [#11]</message>
  <tree>d8fb5b18d814a7e331d40eae76b846b903ee0479</tree>
  <committer>
    <name>Douglas Creager</name>
    <email>dcreager@alum.mit.edu</email>
  </committer>
</commit>
