packages feed

deferred-folds 0.9.15 → 0.9.16

raw patch · 3 files changed

+16/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ DeferredFolds.Unfoldr: intSet :: IntSet -> Unfoldr Int

Files

deferred-folds.cabal view
@@ -1,5 +1,5 @@ name: deferred-folds-version: 0.9.15+version: 0.9.16 category: Folding synopsis: Abstractions over deferred folds description:
library/DeferredFolds/Defs/Unfoldr.hs view
@@ -5,6 +5,7 @@ import DeferredFolds.Types import qualified Data.Map.Strict as Map import qualified Data.IntMap.Strict as IntMap+import qualified Data.IntSet as IntSet import qualified Data.HashMap.Strict as HashMap import qualified Data.ByteString as ByteString import qualified Data.ByteString.Short.Internal as ShortByteString@@ -65,7 +66,8 @@ {-| Apply a Gonzalez fold -} {-# INLINE fold #-} fold :: Fold input output -> Unfoldr input -> output-fold (Fold step init extract) = extract . foldl' step init+fold (Fold step init extract) (Unfoldr run) =+  run (\ input next state -> next $! step state input) extract init  {-| Apply a monadic Gonzalez fold -} {-# INLINE foldM #-}@@ -73,10 +75,20 @@ foldM (FoldM step init extract) (Unfoldr unfoldr) =   init >>= unfoldr (\ input next state -> step state input >>= next) return >>= extract +{-| Construct from any value by supplying a definition of foldr -}+{-# INLINE foldrAndContainer #-}+foldrAndContainer :: (forall x. (elem -> x -> x) -> x -> container -> x) -> container -> Unfoldr elem+foldrAndContainer foldr a = Unfoldr (\ step init -> foldr step init a)+ {-| Construct from any foldable -} {-# INLINE foldable #-} foldable :: Foldable foldable => foldable a -> Unfoldr a-foldable foldable = Unfoldr (\ step init -> foldr step init foldable)+foldable = foldrAndContainer foldr++{-| Elements of IntSet. -}+{-# INLINE intSet #-}+intSet :: IntSet -> Unfoldr Int+intSet = foldrAndContainer IntSet.foldr  {-| Filter the values given a predicate -} {-# INLINE filter #-}
library/DeferredFolds/Unfoldr.hs view
@@ -5,4 +5,4 @@ where  import DeferredFolds.Types as Exports (Unfoldr(..))-import DeferredFolds.Defs.Unfoldr as Exports+import DeferredFolds.Defs.Unfoldr as Exports hiding (foldrAndContainer)