packages feed

strings 1.0.2 → 1.1

raw patch · 4 files changed

+84/−16 lines, 4 filesdep ~bytestringsetup-changed

Dependency ranges changed: bytestring

Files

+ Setup.hs view
@@ -0,0 +1,4 @@+import Distribution.Simple++main = defaultMain+
− Setup.lhs
@@ -1,4 +0,0 @@-import Distribution.Simple--main = defaultMain-
src/Data/Strings.hs view
@@ -26,12 +26,14 @@     bytes,     lazyBytes, +    charToByte,+    byteToChar,+     Str (..),     Strings (..)  ) where - import Data.Int import Data.Word import Data.String hiding (fromString)@@ -64,18 +66,25 @@     | x == '\n' = True     | otherwise = False +charToByte :: Char -> Word8+-- ^ Convert a 'Char' into a 'Word8'.+charToByte = fromIntegral . C.ord --- | Create a 'Text' object form an ordinary Haskell 'String'.+byteToChar :: Word8 -> Char+-- ^ Convert a 'Word8' into a 'Char'.+byteToChar = C.chr . fromIntegral+ text :: String -> Text+-- ^ Create a 'Text' object form an ordinary Haskell 'String'. text = S.fromString --- | Create a lazy 'LazyT.Text' object from an ordinary Haskell 'String'. lazyText :: String -> LazyT.Text+-- ^ Create a lazy 'LazyT.Text' object from an ordinary Haskell 'String'. lazyText = S.fromString --- | Create a 'ByteString' object form an ordinary Haskell 'String'.--- This function will encode a String using the UTF-8 character encoding. bytes :: String -> ByteString+-- ^ Create a 'ByteString' object form an ordinary Haskell 'String'.+-- This function will encode a String using the UTF-8 character encoding. bytes = sFromUnicodeString  -- | Create a lazy 'LazyB.ByteString' object from an ordinary Haskell 'String'.@@ -144,6 +153,18 @@     -- > strSplitAll "xx" "1x2xx3xx4" = ["1x2", "3", "4"]     strSplitAll :: String -> a -> [a] +    -- | Turn all characters in the string to upper case.+    strToUpper :: a -> a+    +    -- | Turn all characters in the string to lower case.+    strToLower :: a -> a++    -- | Turn the first character in the string to upper case.+    strCapitalize :: a -> a++    -- | @map@ generalised.+    strMap :: (Char -> Char) -> a -> a+     -- | @concat@ generalised.     strConcat :: [a] -> a @@ -159,6 +180,9 @@               -> a      -- The string to append to.               -> a      -- The concatenation of the two strings. +    -- | Cons generalised.+    strCons :: Char -> a -> a+     -- | Strips white space characters off both ends of the string.     strTrim :: a -> a @@ -225,6 +249,13 @@       where (a, b, _) = sSplit (fromString d) s     strSplitAll n = sSplitAll (fromString n) +    strToLower = strMap C.toLower+    strToUpper = strMap C.toUpper+    strCapitalize str = strCons (C.toUpper (strHead str)) (strTail str)++    strCons = sCons+    strMap = sMap+     strConcat = sConcat     strJoin d = let d' = fromUnicodeString d in strConcat . L.intersperse d'     strAppend x xs = sConcat [xs, fromString x]@@ -330,6 +361,15 @@     -- | Check if the string ends with the given string.     sEndsWith   :: a -> a -> Bool +    -- | Cons+    sCons :: Char -> a -> a+    +    -- | Turn the first character into an upper case character.+    sCapitalize :: a -> a++    -- | Map a function over all characters.+    sMap :: (Char -> Char) -> a -> a+     -- | Concatenate all the strings in the list to a single string.     sConcat :: [a] -> a @@ -370,6 +410,10 @@     -- | Convert the string into a list of bytes.     sToWord8 :: a -> [Word8] +    sCapitalize xs+        | sNull xs  = xs+        | otherwise = sCons (C.toUpper (sHead xs)) (sTail xs)+     sBreak d src = search 0 src       where         search a b | a `seq` b `seq` False = undefined@@ -437,6 +481,8 @@     sStartsWith = flip B.isPrefixOf     sEndsWith = flip B.isSuffixOf +    sCons = B.cons . charToByte+    sMap f = B.map (charToByte . f . byteToChar)     sConcat = B.concat     sLen = B.length @@ -472,6 +518,8 @@     sStartsWith = flip LazyB.isPrefixOf     sEndsWith = flip LazyB.isSuffixOf +    sCons = LazyB.cons . charToByte+    sMap f = LazyB.map (charToByte . f . byteToChar)     sConcat = LazyB.concat     sLen = fromIntegral . LazyB.length @@ -508,6 +556,8 @@     sStartsWith = flip T.isPrefixOf     sEndsWith = flip T.isSuffixOf +    sCons = T.cons+    sMap = T.map     sConcat = T.concat     sLen = T.length @@ -547,6 +597,8 @@     sStartsWith = flip LazyT.isPrefixOf     sEndsWith = flip LazyT.isSuffixOf +    sCons = LazyT.cons+    sMap = LazyT.map     sConcat = LazyT.concat     sLen = fromIntegral . LazyT.length @@ -583,6 +635,12 @@      sStartsWith = flip L.isPrefixOf     sEndsWith = flip L.isSuffixOf++    sCapitalize (x:xs) = C.toUpper x : xs+    sCapitalize _ = []++    sCons = (:)+    sMap = map      sConcat = concat     sLen = length
strings.cabal view
@@ -1,7 +1,22 @@ Name:           strings-Version:        1.0.2+Version:        1.1+ Synopsis:       Functions for working with strings, including Text, ByteString, etc.-Description:    Functions for working with strings, including Text, ByteString, etc.               ++Description:    This package provides various functions for working with strings,+                such as @join@, @split@, @toUppercase@, etc.+                .+                The functions in this package work with all kinds of strings+                such as Text, ByteString, String, and their respective lazy counter+                parts. There is also an interface which is agnostic of the underlying+                string type.+                .+                [@v1.0.2@] Fixed an issue with @strSplitAll@. Applied to the empty string+                    it should return an empty list, but it returned a list containing+                    a single empty string. It now returns correctly the empty list.+                .+                [@v1.1@] Added @strToUpper@, @strToLower@, @strCapitalize@, @strCons@,+                    and  @strMap@. Also @sCapitalize@, @sCons@, and @sMap@.                  License:        MIT License-File:   LICENSE@@ -16,11 +31,6 @@ Source-Repository head     type: darcs     location: hub.darcs.net:strings--Source-Repository head-    type: darcs-    location: hub.darcs.net:strings-    tag: v1.0.2  Library     Exposed-Modules:    Data.Strings