Commits

Eric Rochester committed bb53e2b

Changed Integer to Int.

  • Participants
  • Parent commits 0c0f181

Comments (0)

Files changed (2)

Test/SequiturUnit.hs

 import qualified Data.Sequitur as Seq
 
 
-testRule :: Seq.Compressor Char -> Integer -> [Seq.Symbol Char] -> Assertion
+testRule :: Seq.Compressor Char -> Int -> [Seq.Symbol Char] -> Assertion
 testRule compressor name expected =
     assertEqual title expList actual
     where actual  = toList $ Seq.rule compressor name

src/Data/Sequitur.hs

 -- | This is a Symbol in a rule.
 data Symbol a =
       Literal a                 -- A literal input symbol.
-    | Rule Integer (RuleBody a) -- A rule.
+    | Rule Int (RuleBody a)     -- A rule.
     deriving (Show, Eq)
 
 -- | This is a rule's body
 
 -- | This is the compressor data types.
 data Compressor a = Compressor {
-      rules       :: M.Map Integer (RuleBody a)     -- The list of rules defined.
-    , ruleCount   :: Integer                        -- The number of rules defined.
-    , ruleUtility :: M.Map Integer Integer          -- The number of times each rule is used.
-    , digramIndex :: M.Map (a, a) (Symbol a)        -- An index from a digram pair to the
-                                                    -- place it's used in the grammar.
+      rules       :: M.Map Int (RuleBody a)     -- The list of rules defined.
+    , ruleCount   :: Int                        -- The number of rules defined.
+    , ruleUtility :: M.Map Int Int              -- The number of times each rule is used.
+    , digramIndex :: M.Map (a, a) (Symbol a)    -- An index from a digram pair to the
+                                                -- place it's used in the grammar.
     }
 
 -- | This serializes a 
 
 -- | This returns the rule of a given number.
-rule :: Eq a => Compressor a -> Integer -> RuleBody a
+rule :: Eq a => Compressor a -> Int -> RuleBody a
 rule compressor key =
     M.findWithDefault S.empty key $ rules compressor
 
 -- | This feeds an input literal to a compressor and returns a new compressor
 -- that includes it.
 feed :: Eq a => Compressor a -> a -> Compressor a
-feed compressor _ = compressor
+feed compressor item =
+    c0 = append compressor 0 item
 
 -- | This appends a symbol to a rule.
-append :: Eq a => Compressor a -> Integer -> a -> Compressor a
+append :: Eq a => Compressor a -> Int -> a -> Compressor a
 append compressor _ _ = compressor
 
 -- | This uses an existing rule.
-use :: Compressor a -> Integer -> Compressor a
+use :: Compressor a -> Int -> Compressor a
 use compressor _ = compressor
 
 -- | This creates a new rule.
-create :: Compressor a -> (Integer, Compressor a)
+create :: Compressor a -> (Int, Compressor a)
 create compressor = (0, compressor)
 
 -- | This deletes a rule.
-delete :: Compressor a -> Integer -> Compressor a
+delete :: Compressor a -> Int -> Compressor a
 delete compressor _ = compressor