deferred-folds-0.9.18.7: Abstractions over deferred folds

Safe Haskell | None
Language | Haskell2010

DeferredFolds.UnfoldlM

Synopsis

- unfoldr :: forall (m :: Type -> Type) a. Monad m => Unfoldr a -> UnfoldlM m a
- filter :: Monad m => (a -> m Bool) -> UnfoldlM m a -> UnfoldlM m a
- null :: Monad m => UnfoldlM m input -> m Bool
- fold :: Fold input output -> UnfoldlM Identity input -> output
- mapM_ :: Monad m => (input -> m ()) -> UnfoldlM m input -> m ()
- forM_ :: Monad m => UnfoldlM m input -> (input -> m ()) -> m ()
- foldM :: Monad m => FoldM m input output -> UnfoldlM m input -> m output
- hoist :: (forall a1. m a1 -> n a1) -> (forall a1. n a1 -> m a1) -> UnfoldlM m a -> UnfoldlM n a
- foldlM' :: Monad m => (output -> input -> m output) -> output -> UnfoldlM m input -> m output
- newtype UnfoldlM (m :: Type -> Type) a = UnfoldlM (forall x. (x -> a -> m x) -> x -> m x)
- foldable :: forall (m :: Type -> Type) foldable a. (Monad m, Foldable foldable) => foldable a -> UnfoldlM m a
- mapFoldMInput :: forall (m :: Type -> Type) b a. Monad m => (forall x. FoldM m b x -> FoldM m a x) -> UnfoldlM m a -> UnfoldlM m b
- foldlRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. (x -> a -> x) -> x -> x) -> UnfoldlM m a
- foldrRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. (a -> x -> x) -> x -> x) -> UnfoldlM m a
- intsInRange :: forall (m :: Type -> Type). Monad m => Int -> Int -> UnfoldlM m Int
- tVarValue :: TVar a -> UnfoldlM STM a
- byteStringBytes :: ByteString -> UnfoldlM IO Word8
- shortByteStringBytes :: forall (m :: Type -> Type). Monad m => ShortByteString -> UnfoldlM m Word8
- primArray :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m prim
- primArrayWithIndices :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m (Int, prim)

# Documentation

unfoldr :: forall (m :: Type -> Type) a. Monad m => Unfoldr a -> UnfoldlM m a Source #

filter :: Monad m => (a -> m Bool) -> UnfoldlM m a -> UnfoldlM m a Source #

Filter the values given a predicate

null :: Monad m => UnfoldlM m input -> m Bool Source #

Check whether it's empty

fold :: Fold input output -> UnfoldlM Identity input -> output Source #

Apply a Gonzalez fold

mapM_ :: Monad m => (input -> m ()) -> UnfoldlM m input -> m () Source #

A more efficient implementation of mapM_

forM_ :: Monad m => UnfoldlM m input -> (input -> m ()) -> m () Source #

Same as `mapM_` with arguments flipped

foldM :: Monad m => FoldM m input output -> UnfoldlM m input -> m output Source #

Apply a monadic Gonzalez fold

hoist :: (forall a1. m a1 -> n a1) -> (forall a1. n a1 -> m a1) -> UnfoldlM m a -> UnfoldlM n a Source #

Change the base monad using invariant natural transformations

foldlM' :: Monad m => (output -> input -> m output) -> output -> UnfoldlM m input -> m output Source #

Perform a monadic strict left fold

newtype UnfoldlM (m :: Type -> Type) a Source #

A monadic variation of DeferredFolds.Unfoldl

Constructors

UnfoldlM (forall x. (x -> a -> m x) -> x -> m x) |

#### Instances

Instances details

MonadTrans UnfoldlM Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods lift :: Monad m => m a -> UnfoldlM m a Source #
Monad m => Alternative (UnfoldlM m) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods empty :: UnfoldlM m a Source # (<|>) :: UnfoldlM m a -> UnfoldlM m a -> UnfoldlM m a Source # some :: UnfoldlM m a -> UnfoldlM m [a] Source # many :: UnfoldlM m a -> UnfoldlM m [a] Source #
Monad m => Applicative (UnfoldlM m) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods pure :: a -> UnfoldlM m a Source # (<*>) :: UnfoldlM m (a -> b) -> UnfoldlM m a -> UnfoldlM m b Source # liftA2 :: (a -> b -> c) -> UnfoldlM m a -> UnfoldlM m b -> UnfoldlM m c Source # (*>) :: UnfoldlM m a -> UnfoldlM m b -> UnfoldlM m b Source # (<*) :: UnfoldlM m a -> UnfoldlM m b -> UnfoldlM m a Source #
Functor m => Functor (UnfoldlM m) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods fmap :: (a -> b) -> UnfoldlM m a -> UnfoldlM m b Source # (<$) :: a -> UnfoldlM m b -> UnfoldlM m a Source #
Monad m => Monad (UnfoldlM m) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods (>>=) :: UnfoldlM m a -> (a -> UnfoldlM m b) -> UnfoldlM m b Source # (>>) :: UnfoldlM m a -> UnfoldlM m b -> UnfoldlM m b Source # return :: a -> UnfoldlM m a Source #
Monad m => MonadPlus (UnfoldlM m) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods mzero :: UnfoldlM m a Source # mplus :: UnfoldlM m a -> UnfoldlM m a -> UnfoldlM m a Source #
Foldable (UnfoldlM Identity) Source # |

Instance details

Defined in DeferredFolds.Defs.UnfoldlM

Methods

fold :: Monoid m => UnfoldlM Identity m -> m Source #

foldMap :: Monoid m => (a -> m) -> UnfoldlM Identity a -> m Source #

foldMap' :: Monoid m => (a -> m) -> UnfoldlM Identity a -> m Source #

foldr :: (a -> b -> b) -> b -> UnfoldlM Identity a -> b Source #

foldr' :: (a -> b -> b) -> b -> UnfoldlM Identity a -> b Source #

foldl :: (b -> a -> b) -> b -> UnfoldlM Identity a -> b Source #

foldl' :: (b -> a -> b) -> b -> UnfoldlM Identity a -> b Source #

foldr1 :: (a -> a -> a) -> UnfoldlM Identity a -> a Source #

foldl1 :: (a -> a -> a) -> UnfoldlM Identity a -> a Source #

toList :: UnfoldlM Identity a -> [a] Source #

null :: UnfoldlM Identity a -> Bool Source #

length :: UnfoldlM Identity a -> Int Source #

elem :: Eq a => a -> UnfoldlM Identity a -> Bool Source #

maximum :: Ord a => UnfoldlM Identity a -> a Source #

minimum :: Ord a => UnfoldlM Identity a -> a Source #

sum :: Num a => UnfoldlM Identity a -> a Source #

product :: Num a => UnfoldlM Identity a -> a Source #

Monad m => Monoid (UnfoldlM m a) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods mempty :: UnfoldlM m a Source # mappend :: UnfoldlM m a -> UnfoldlM m a -> UnfoldlM m a Source # mconcat :: [UnfoldlM m a] -> UnfoldlM m a Source #
Monad m => Semigroup (UnfoldlM m a) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods (<>) :: UnfoldlM m a -> UnfoldlM m a -> UnfoldlM m a Source # sconcat :: NonEmpty (UnfoldlM m a) -> UnfoldlM m a Source # stimes :: Integral b => b -> UnfoldlM m a -> UnfoldlM m a Source #
IsList (UnfoldlM Identity a) Source # |

Instance details

Defined in DeferredFolds.Defs.UnfoldlM

Associated Types

type Item (UnfoldlM Identity a) |
Instance details Defined in DeferredFolds.Defs.UnfoldlM type Item (UnfoldlM Identity a) = a

Methods

fromList :: [Item (UnfoldlM Identity a)] -> UnfoldlM Identity a Source #

fromListN :: Int -> [Item (UnfoldlM Identity a)] -> UnfoldlM Identity a Source #

toList :: UnfoldlM Identity a -> [Item (UnfoldlM Identity a)] Source #

Show a => Show (UnfoldlM Identity a) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods showsPrec :: Int -> UnfoldlM Identity a -> ShowS Source # show :: UnfoldlM Identity a -> String Source # showList :: [UnfoldlM Identity a] -> ShowS Source #
Eq a => Eq (UnfoldlM Identity a) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM Methods (==) :: UnfoldlM Identity a -> UnfoldlM Identity a -> Bool Source # (/=) :: UnfoldlM Identity a -> UnfoldlM Identity a -> Bool Source #
type Item (UnfoldlM Identity a) Source # |
Instance details Defined in DeferredFolds.Defs.UnfoldlM type Item (UnfoldlM Identity a) = a

foldable :: forall (m :: Type -> Type) foldable a. (Monad m, Foldable foldable) => foldable a -> UnfoldlM m a Source #

Construct from any foldable

mapFoldMInput :: forall (m :: Type -> Type) b a. Monad m => (forall x. FoldM m b x -> FoldM m a x) -> UnfoldlM m a -> UnfoldlM m b Source #

Lift a fold input mapping function into a mapping of unfolds

foldlRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. (x -> a -> x) -> x -> x) -> UnfoldlM m a Source #

Construct from a specification of how to execute a left-fold

foldrRunner :: forall (m :: Type -> Type) a. Monad m => (forall x. (a -> x -> x) -> x -> x) -> UnfoldlM m a Source #

Construct from a specification of how to execute a right-fold

intsInRange :: forall (m :: Type -> Type). Monad m => Int -> Int -> UnfoldlM m Int Source #

Ints in the specified inclusive range

tVarValue :: TVar a -> UnfoldlM STM a Source #

TVar contents

byteStringBytes :: ByteString -> UnfoldlM IO Word8 Source #

Bytes of a bytestring

shortByteStringBytes :: forall (m :: Type -> Type). Monad m => ShortByteString -> UnfoldlM m Word8 Source #

Bytes of a short bytestring

primArray :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m prim Source #

Elements of a prim array

primArrayWithIndices :: forall (m :: Type -> Type) prim. (Monad m, Prim prim) => PrimArray prim -> UnfoldlM m (Int, prim) Source #

Elements of a prim array coming paired with indices