List 0.5.0 → 0.5.1
raw patch · 2 files changed
+18/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.List.Class: splitWhenM :: List l => (a -> ItemM l Bool) -> l a -> ItemM l ([a], l a)
Files
- List.cabal +1/−1
- src/Data/List/Class.hs +17/−2
List.cabal view
@@ -1,5 +1,5 @@ Name: List-Version: 0.5.0+Version: 0.5.1 Category: Control Synopsis: List monad transformer and class Description:
src/Data/List/Class.hs view
@@ -16,12 +16,12 @@ tail, enumFrom, enumFromTo, catMaybes, mapMaybe,- -- Which broke with the release of List-0.4.3 due to unqualified imports. -- | Non standard List operations foldrL, foldlL, foldl1L, toList, lengthL, lastL, merge2On, mergeOn, -- | Operations useful for monadic lists- execute, joinM, mapL, filterL, iterateM, takeWhileM, repeatM, splitAtM,+ execute, joinM, mapL, filterL, iterateM, takeWhileM, repeatM,+ splitAtM, splitWhenM, -- | Operations for non-monadic lists sortOn, -- | Convert between List types@@ -317,6 +317,21 @@ Cons x xs -> do (pre, post) <- splitAtM (at-1) xs return (x:pre, post)++-- | Monadic variant of break.+-- Consumes items from the list until a condition holds.+splitWhenM :: List l => (a -> ItemM l Bool) -> l a -> ItemM l ([a], l a)+splitWhenM cond list = do+ item <- runList list+ case item of+ Nil -> return ([], mzero)+ Cons x xs -> do+ isSplit <- cond x+ if isSplit+ then return ([], cons x xs)+ else do+ (pre, post) <- splitWhenM cond xs+ return (x:pre, post) -- | listStateJoin can transform a -- @ListT (StateT s m) a@ to a @StateT s m (ListT m a)@.