split 0.1 → 0.1.1
raw patch · 4 files changed
+46/−17 lines, 4 files
Files
- Data/List/Split.hs +13/−8
- Data/List/Split/Internals.hs +16/−0
- Properties.hs +15/−5
- split.cabal +2/−4
Data/List/Split.hs view
@@ -28,7 +28,6 @@ -- * Convenience functions -- $conv - splitOn , splitOneOf , splitWhen@@ -39,6 +38,9 @@ , unintercalate + , wordsBy+ , linesBy+ -- * Other splitting methods -- $other , splitEvery@@ -60,9 +62,8 @@ , whenElt -- ** Strategy transformers- --- -- $ Functions for altering splitting strategy- -- parameters.+ -- $transform+ , dropDelims , keepDelimsL , keepDelimsR@@ -71,10 +72,8 @@ , dropFinalBlank -- ** Derived combinators- --- -- $ Combinators which can be defined in terms of- -- other combinators, but are provided for- -- convenience.+ -- $derived+ , dropBlanks , startsWith , startsWithOneOf@@ -139,3 +138,9 @@ -- All these basic strategies have the same parameters as the -- 'defaultSplitter' except for the delimiter. +-- $transform+-- Functions for altering splitting strategy parameters.++-- $derived+-- Combinators which can be defined in terms of other combinators, but+-- are provided for convenience.
Data/List/Split/Internals.hs view
@@ -423,6 +423,22 @@ unintercalate :: Eq a => [a] -> [a] -> [[a]] unintercalate = sepBy +-- | Split into words, with word boundaries indicated by the given+-- predicate. Satisfies @words === wordsBy isSpace@; equivalent to+-- @split . dropBlanks . dropDelims . whenElt@. For example:+--+-- > wordsBy (=='x') "dogxxxcatxbirdxx" == ["dog","cat","bird"]+wordsBy :: (a -> Bool) -> [a] -> [[a]]+wordsBy = split . dropBlanks . dropDelims . whenElt++-- | Split into lines, with line boundaries indicated by the given+-- predicate. Satisfies @lines === linesBy (=='\n')@; equivalent to+-- @split . dropFinalBlank . dropDelims . whenElt@. For example:+--+-- > linesBy (=='x') "dogxxxcatxbirdxx" == ["dog","","","cat","bird",""]+linesBy :: (a -> Bool) -> [a] -> [[a]]+linesBy = split . dropFinalBlank . dropDelims . whenElt+ -- * Other splitting methods -- | @'splitEvery' n@ splits a list into length-n pieces. The last
Properties.hs view
@@ -105,6 +105,8 @@ , ("splitPlaces/last <= n", qc prop_splitPlaces_last_less_n) , ("splitPlaces/preserve", qc prop_splitPlaces_preserve) , ("lines", qc prop_lines)+ , ("wordsBy/words", qc prop_wordsBy_words)+ , ("linesBy/lines", qc prop_linesBy_lines) ] prop_default_id :: [Elt] -> Bool@@ -291,12 +293,20 @@ mInit [x] = [] mInit (x:xs) = x : init xs -newtype EltNL = EltNL { unEltNL :: Char }+newtype EltWS = EltWS { unEltWS :: Char } deriving (Eq, Show) -instance Arbitrary EltNL where- arbitrary = elements (map EltNL "abcde\n")+instance Arbitrary EltWS where+ arbitrary = elements (map EltWS "abcde \n") -prop_lines :: [EltNL] -> Bool+prop_lines :: [EltWS] -> Bool prop_lines s = lines s' == endBy "\n" s'- where s' = map unEltNL s+ where s' = map unEltWS s++prop_wordsBy_words :: [EltWS] -> Bool+prop_wordsBy_words s = words s' == wordsBy isSpace s'+ where s' = map unEltWS s++prop_linesBy_lines :: [EltWS] -> Bool+prop_linesBy_lines s = lines s' == linesBy (=='\n') s'+ where s' = map unEltWS s
split.cabal view
@@ -1,5 +1,5 @@ Name: split-Version: 0.1+Version: 0.1.1 Stability: experimental Description: Combinator library and utility functions for splitting lists. Homepage: http://code.haskell.org/~byorgey/code/split@@ -18,8 +18,6 @@ default: False library- ghc-options: -Wall- if flag(testing)- ghc-options: -Werror+ ghc-options: -Wall Build-Depends: base Exposed-Modules: Data.List.Split, Data.List.Split.Internals