Commits

Bryan O'Sullivan committed 1ab26a2

Fix set-related bugs

  • Participants
  • Parent commits 2b656f5

Comments (0)

Files changed (1)

File src/Data/ParserCombinators/Attoparsec/FastSet.hs

     ) where
 
 import Data.Bits ((.&.), (.|.), shiftR)
+import qualified Data.ByteString.Char8 as B8
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Internal as I
 import qualified Data.ByteString.Unsafe as U
     deriving (Eq, Ord)
 
 instance Show FastSet where
-    show _ = "FastSet"
+    show (Sorted s) = "FastSet Sorted " ++ show (B8.unpack s)
+    show (Table _) = "FastSet Table"
 
 -- | The lower bound on the size of a lookup table.  We choose this to
 -- balance table density against performance.
               | otherwise =
                   let mid = (lo + hi) `div` 2
                   in case compare w (U.unsafeIndex s mid) of
-                       GT -> search lo (mid - 1)
-                       LT -> search (mid + 1) hi
+                       GT -> search (mid + 1) hi
+                       LT -> search lo (mid - 1)
                        _ -> True
 
 -- | Check the set for membership.  Only works with 8-bit characters: