packages feed

split 0.1.2.3 → 0.1.3

raw patch · 5 files changed

+38/−4 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

CHANGES view
@@ -1,3 +1,7 @@+* 0.1.3++  - Add 'chop' list-processing function.+ * 0.1.2.3    - Now builds with GHC 7
Data/List/Split.hs view
@@ -46,6 +46,7 @@                        , splitEvery                        , chunk                        , splitPlaces+                       , chop                         -- * Splitting combinators                        -- $comb
Data/List/Split/Internals.hs view
@@ -499,3 +499,22 @@   splitPlacer _ [] _ n      = n   splitPlacer (l:ls) xs c n = let (x1, x2) = genericSplitAt l xs                               in  x1 `c` splitPlacer ls x2 c n++-- | A useful recursion pattern for processing a list to produce a new+--   list, often used for \"chopping\" up the input list.  Typically+--   chop is called with some function that will consume an initial+--   prefix of the list and produce a value and the rest of the list.+--+--   For example, many common Prelude functions can be implemented in+--   terms of @chop@:+--+-- > group :: (Eq a) => [a] -> [[a]]+-- > group = chop (\ xs@(x:_) -> span (==x) xs)+-- >+-- > words :: String -> [String]+-- > words = filter (not . null) . chop (span (not . isSpace) . dropWhile isSpace)++chop :: ([a] -> (b, [a])) -> [a] -> [b]+chop _ [] = []+chop f as = b : chop f as'+  where (b, as') = f as
Properties.hs view
@@ -9,7 +9,7 @@ import Control.Monad  import Data.Char-import Data.List (isInfixOf, isPrefixOf, isSuffixOf, tails, intercalate, genericTake)+import Data.List (isInfixOf, isPrefixOf, isSuffixOf, tails, intercalate, genericTake, group) import Data.Maybe (isJust)  newtype Elt = Elt { unElt :: Char }@@ -108,6 +108,8 @@             , ("lines",                         qc prop_lines)             , ("wordsBy/words",                 qc prop_wordsBy_words)             , ("linesBy/lines",                 qc prop_linesBy_lines)+            , ("chop/group",                    qc prop_chop_group)+            , ("chop/words",                    qc prop_chop_words)             ]  prop_default_id :: [Elt] -> Bool@@ -313,4 +315,11 @@  prop_linesBy_lines :: [EltWS] -> Bool prop_linesBy_lines s = lines s' == linesBy (=='\n') s'+  where s' = map unEltWS s++prop_chop_group :: [Elt] -> Bool+prop_chop_group s = chop (\xs@(x:_) -> span (==x) xs) s == group s++prop_chop_words :: [EltWS] -> Bool+prop_chop_words s = words s' == (filter (not . null) . chop (span (not . isSpace) . dropWhile isSpace) $ s')   where s' = map unEltWS s
split.cabal view
@@ -1,6 +1,6 @@ Name:                split-Version:             0.1.2.3-Stability:           experimental+Version:             0.1.3+Stability:           stable Description:         Combinator library and utility functions for splitting lists. Homepage:            http://code.haskell.org/~byorgey/code/split Synopsis:            Combinator library for splitting lists.@@ -12,6 +12,7 @@ Category:            List Build-type:          Simple Cabal-Version:       >= 1.2+Tested-with:         GHC == 6.12.3, GHC ==7.0.1  flag testing   description: Testing mode@@ -19,5 +20,5 @@  library   ghc-options:       -Wall-  Build-Depends:     base <5+  Build-Depends:     base <4.4   Exposed-Modules:   Data.List.Split, Data.List.Split.Internals