case-insensitive 0.1 → 0.2
raw patch · 2 files changed
+26/−16 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.CaseInsensitive: instance FoldCase s => FoldCase [s]
+ Data.CaseInsensitive: foldedCase :: CI s -> s
+ Data.CaseInsensitive: instance FoldCase String
Files
- Data/CaseInsensitive.hs +23/−13
- case-insensitive.cabal +3/−3
Data/CaseInsensitive.hs view
@@ -23,6 +23,7 @@ module Data.CaseInsensitive ( CI , mk , original+ , foldedCase , map , FoldCase(foldCase) ) where@@ -41,6 +42,7 @@ import Data.String ( IsString(fromString) ) import Data.Typeable ( Typeable ) import Data.Char ( Char )+import Prelude ( String ) import Text.Read ( Read(readPrec) ) import Text.Show ( Show(showsPrec), ShowS ) import qualified Data.List as L ( map )@@ -64,7 +66,7 @@ -------------------------------------------------------------------------------- {-| A @CI s@ provides /C/ase /I/nsensitive comparison for the string-like type-@s@ (for example: @String@, @Text@, @ByteString@, @ShowS@, etc.).+@s@ (for example: 'String', 'T.Text', 'B.ByteString', 'ShowS', etc.). Note that @CI s@ has an instance for 'IsString' which together with the @OverloadedStrings@ language extension allows you to write case insensitive@@ -77,7 +79,8 @@ -} data CI s = CI { original ∷ !s -- ^ Retrieve the original string-like value.- , lowerCased ∷ !s+ , foldedCase ∷ !s -- ^ Retrieve the case folded string-like value.+ -- (Also see 'foldCase'). } deriving Typeable @@ -97,10 +100,10 @@ CI o1 l1 `mappend` CI o2 l2 = CI (o1 `mappend` o2) (l1 `mappend` l2) instance Eq s ⇒ Eq (CI s) where- (==) = (==) `on` lowerCased+ (==) = (==) `on` foldedCase instance Ord s ⇒ Ord (CI s) where- compare = compare `on` lowerCased+ compare = compare `on` foldedCase instance (Read s, FoldCase s) ⇒ Read (CI s) where readPrec = fmap mk readPrec@@ -115,17 +118,24 @@ -- | Class of string-like types that support folding cases. ----- For 'Char' this means 'toLower' and for 'T.Text' this means 'T.toCaseFold'.+-- Note that the instances for 'Char', 'String', 'ShowS' and the 'B.ByteString'+-- types do /not/ perform fully correct Unicode-aware case folding, they simply+-- 'toLower' their characters! This is of course more than suitable for ASCII+-- encoded strings.+--+-- The instances for the 'T.Text' types use 'T.toCaseFold' which performs a+-- better Unicode-aware case fold which is more suitable for case insensitive+-- string comparisons. class FoldCase s where foldCase ∷ s → s -instance FoldCase Char where foldCase = toLower-instance FoldCase s ⇒ FoldCase [s] where foldCase = L.map foldCase-instance FoldCase B.ByteString where foldCase = C8.map toLower-instance FoldCase BL.ByteString where foldCase = BLC8.map toLower-instance FoldCase T.Text where foldCase = T.toCaseFold-instance FoldCase TL.Text where foldCase = TL.toCaseFold-instance FoldCase ShowS where foldCase = (foldCase ∘)-instance FoldCase (CI s) where foldCase (CI _ l) = CI l l+instance FoldCase Char where foldCase = toLower+instance FoldCase String where foldCase = L.map toLower+instance FoldCase B.ByteString where foldCase = C8.map toLower+instance FoldCase BL.ByteString where foldCase = BLC8.map toLower+instance FoldCase T.Text where foldCase = T.toCaseFold+instance FoldCase TL.Text where foldCase = TL.toCaseFold+instance FoldCase ShowS where foldCase = (foldCase ∘)+instance FoldCase (CI s) where foldCase (CI _ l) = CI l l -- The End ---------------------------------------------------------------------
case-insensitive.cabal view
@@ -1,5 +1,5 @@ name: case-insensitive-version: 0.1+version: 0.2 cabal-version: >=1.6 build-type: Simple license: BSD3@@ -12,8 +12,8 @@ description: The module @Data.CaseInsensitive@ provides the 'CI' type constructor which can be parameterised by a string-like type like: 'String', 'ByteString', 'Text',- etc.. Comparisons of values of the resulting type are- then insensitive to cases.+ etc.. Comparisons of values of the resulting type will be+ insensitive to cases. source-repository head Type: darcs