Haskell Platform proposal: Add case-insensitive

Bas van Dijk v.dijk.bas at gmail.com
Mon Jan 28 10:47:40 GMT 2013


Adding the following rewrite rule makes the "case-insensitve"
benchmark as fast as the "no-class" benchmark:

{-# RULES
  "mk/ByteString" forall (bs :: B.ByteString). mk bs = CI bs (foldCaseBS bs)
  #-}

foldCaseBS :: B.ByteString -> B.ByteString
foldCaseBS bs = B.map toLower8' bs
    where
      toLower8' :: Word8 -> Word8
      toLower8' w
          |  65  <= w && w <=  90 ||
             192 <= w && w <= 214 ||
             216 <= w && w <= 222 = w + 32
          | otherwise             = w

Strangely, using the existing foldCase method or the toLower8 function
makes the code slow again.

I committed[1] this to the "hp" branch.

Bas

[1] https://github.com/basvandijk/case-insensitive/commit/158e0f02a7832ebe7e46f5784f87a0923e8ea3e6



More information about the Haskell-platform mailing list