zerem-0.0.0.0: Fusing Functor-general effectful streams.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Zerem

Synopsis

Purpose

.

data Zerem f m r Source #

The stream datatype. It consists of a state machine, and an action that yields the initial state.

Constructors

forall s. Zerem (s -> m (Step s f r)) (m s) 

Instances

Instances details
MFunctor (Zerem f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Zerem

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> Zerem f m b -> Zerem f n b

MonadTrans (Zerem a) Source # 
Instance details

Defined in Zerem

Methods

lift :: Monad m => m a0 -> Zerem a m a0 #

(Functor f, Monad m) => Applicative (Zerem f m) Source #

Not lazy on its arguments. If you use something like:

as = yield a *> as

the program will go into an infinite loop.

For that kind of construction, consider using functions from the Generating section, or simply writing a stream by hand:

as = Zerem next (pure a) where
  next a = pure $ Z.Yield (a, a)
Instance details

Defined in Zerem

Methods

pure :: a -> Zerem f m a #

(<*>) :: Zerem f m (a -> b) -> Zerem f m a -> Zerem f m b #

liftA2 :: (a -> b -> c) -> Zerem f m a -> Zerem f m b -> Zerem f m c #

(*>) :: Zerem f m a -> Zerem f m b -> Zerem f m b #

(<*) :: Zerem f m a -> Zerem f m b -> Zerem f m a #

Functor m => Functor (Zerem f m) Source # 
Instance details

Defined in Zerem

Methods

fmap :: (a -> b) -> Zerem f m a -> Zerem f m b #

(<$) :: a -> Zerem f m b -> Zerem f m a #

(Functor f, Monad m) => Monad (Zerem f m) Source # 
Instance details

Defined in Zerem

Methods

(>>=) :: Zerem f m a -> (a -> Zerem f m b) -> Zerem f m b #

(>>) :: Zerem f m a -> Zerem f m b -> Zerem f m b #

return :: a -> Zerem f m a #

(Functor f, Monad m) => Monoid (Zerem f m ()) Source # 
Instance details

Defined in Zerem

Methods

mempty :: Zerem f m () #

mappend :: Zerem f m () -> Zerem f m () -> Zerem f m () #

mconcat :: [Zerem f m ()] -> Zerem f m () #

(Functor f, Monad m) => Semigroup (Zerem f m r) Source # 
Instance details

Defined in Zerem

Methods

(<>) :: Zerem f m r -> Zerem f m r -> Zerem f m r #

sconcat :: NonEmpty (Zerem f m r) -> Zerem f m r #

stimes :: Integral b => b -> Zerem f m r -> Zerem f m r #

data Step s f r Source #

Constructors

Done r

Stream is over and r is the result.

Skip s

Stream is transitioning state without yielding.

Yield !(f s)

Stream yields a functor. Usually (a, s).

Instances

Instances details
Foldable (Step s f) Source # 
Instance details

Defined in Zerem

Methods

fold :: Monoid m => Step s f m -> m #

foldMap :: Monoid m => (a -> m) -> Step s f a -> m #

foldMap' :: Monoid m => (a -> m) -> Step s f a -> m #

foldr :: (a -> b -> b) -> b -> Step s f a -> b #

foldr' :: (a -> b -> b) -> b -> Step s f a -> b #

foldl :: (b -> a -> b) -> b -> Step s f a -> b #

foldl' :: (b -> a -> b) -> b -> Step s f a -> b #

foldr1 :: (a -> a -> a) -> Step s f a -> a #

foldl1 :: (a -> a -> a) -> Step s f a -> a #

toList :: Step s f a -> [a] #

null :: Step s f a -> Bool #

length :: Step s f a -> Int #

elem :: Eq a => a -> Step s f a -> Bool #

maximum :: Ord a => Step s f a -> a #

minimum :: Ord a => Step s f a -> a #

sum :: Num a => Step s f a -> a #

product :: Num a => Step s f a -> a #

Traversable (Step s f) Source # 
Instance details

Defined in Zerem

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Step s f a -> f0 (Step s f b) #

sequenceA :: Applicative f0 => Step s f (f0 a) -> f0 (Step s f a) #

mapM :: Monad m => (a -> m b) -> Step s f a -> m (Step s f b) #

sequence :: Monad m => Step s f (m a) -> m (Step s f a) #

Functor (Step s f) Source # 
Instance details

Defined in Zerem

Methods

fmap :: (a -> b) -> Step s f a -> Step s f b #

(<$) :: a -> Step s f b -> Step s f a #

next :: (Functor f, Monad m) => Zerem f m r -> m (Either r (f (Zerem f m r))) Source #

next_ :: (Functor f, Monad m) => Zerem f m r -> m (Maybe (f (Zerem f m r))) Source #

data InitZerem f m r Source #

Constructors

forall s. InitZerem (s -> m (Step s f r)) s 

initZerem :: Monad m => Zerem f m r -> m (InitZerem f m r) Source #

newtype ZipZerem r m a Source #

Constructors

ZipZerem 

Fields

Instances

Instances details
MFunctor (ZipZerem r :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Zerem

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> ZipZerem r m b -> ZipZerem r n b

MonadTrans (ZipZerem Void) Source # 
Instance details

Defined in Zerem

Methods

lift :: Monad m => m a -> ZipZerem Void m a #

Foldable (ZipZerem r Identity) Source # 
Instance details

Defined in Zerem

Methods

fold :: Monoid m => ZipZerem r Identity m -> m #

foldMap :: Monoid m => (a -> m) -> ZipZerem r Identity a -> m #

foldMap' :: Monoid m => (a -> m) -> ZipZerem r Identity a -> m #

foldr :: (a -> b -> b) -> b -> ZipZerem r Identity a -> b #

foldr' :: (a -> b -> b) -> b -> ZipZerem r Identity a -> b #

foldl :: (b -> a -> b) -> b -> ZipZerem r Identity a -> b #

foldl' :: (b -> a -> b) -> b -> ZipZerem r Identity a -> b #

foldr1 :: (a -> a -> a) -> ZipZerem r Identity a -> a #

foldl1 :: (a -> a -> a) -> ZipZerem r Identity a -> a #

toList :: ZipZerem r Identity a -> [a] #

null :: ZipZerem r Identity a -> Bool #

length :: ZipZerem r Identity a -> Int #

elem :: Eq a => a -> ZipZerem r Identity a -> Bool #

maximum :: Ord a => ZipZerem r Identity a -> a #

minimum :: Ord a => ZipZerem r Identity a -> a #

sum :: Num a => ZipZerem r Identity a -> a #

product :: Num a => ZipZerem r Identity a -> a #

Traversable (ZipZerem () Identity) Source # 
Instance details

Defined in Zerem

Methods

traverse :: Applicative f => (a -> f b) -> ZipZerem () Identity a -> f (ZipZerem () Identity b) #

sequenceA :: Applicative f => ZipZerem () Identity (f a) -> f (ZipZerem () Identity a) #

mapM :: Monad m => (a -> m b) -> ZipZerem () Identity a -> m (ZipZerem () Identity b) #

sequence :: Monad m => ZipZerem () Identity (m a) -> m (ZipZerem () Identity a) #

Monad m => Alternative (ZipZerem () m) Source # 
Instance details

Defined in Zerem

Methods

empty :: ZipZerem () m a #

(<|>) :: ZipZerem () m a -> ZipZerem () m a -> ZipZerem () m a #

some :: ZipZerem () m a -> ZipZerem () m [a] #

many :: ZipZerem () m a -> ZipZerem () m [a] #

Applicative (ZipZerem Void Identity) Source # 
Instance details

Defined in Zerem

Monad m => Applicative (ZipZerem r m) Source # 
Instance details

Defined in Zerem

Methods

pure :: a -> ZipZerem r m a #

(<*>) :: ZipZerem r m (a -> b) -> ZipZerem r m a -> ZipZerem r m b #

liftA2 :: (a -> b -> c) -> ZipZerem r m a -> ZipZerem r m b -> ZipZerem r m c #

(*>) :: ZipZerem r m a -> ZipZerem r m b -> ZipZerem r m b #

(<*) :: ZipZerem r m a -> ZipZerem r m b -> ZipZerem r m a #

Functor m => Functor (ZipZerem r m) Source # 
Instance details

Defined in Zerem

Methods

fmap :: (a -> b) -> ZipZerem r m a -> ZipZerem r m b #

(<$) :: a -> ZipZerem r m b -> ZipZerem r m a #

Monad (ZipZerem Void Identity) Source # 
Instance details

Defined in Zerem

Comonad (ZipZerem Void Identity) Source # 
Instance details

Defined in Zerem

ComonadApply (ZipZerem Void Identity) Source # 
Instance details

Defined in Zerem

newtype ListZerem r m a Source #

Constructors

ListZerem 

Fields

Instances

Instances details
MFunctor (ListZerem r :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Zerem

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> ListZerem r m b -> ListZerem r n b

MonadTrans (ListZerem ()) Source # 
Instance details

Defined in Zerem

Methods

lift :: Monad m => m a -> ListZerem () m a #

Foldable (ListZerem r Identity) Source # 
Instance details

Defined in Zerem

Methods

fold :: Monoid m => ListZerem r Identity m -> m #

foldMap :: Monoid m => (a -> m) -> ListZerem r Identity a -> m #

foldMap' :: Monoid m => (a -> m) -> ListZerem r Identity a -> m #

foldr :: (a -> b -> b) -> b -> ListZerem r Identity a -> b #

foldr' :: (a -> b -> b) -> b -> ListZerem r Identity a -> b #

foldl :: (b -> a -> b) -> b -> ListZerem r Identity a -> b #

foldl' :: (b -> a -> b) -> b -> ListZerem r Identity a -> b #

foldr1 :: (a -> a -> a) -> ListZerem r Identity a -> a #

foldl1 :: (a -> a -> a) -> ListZerem r Identity a -> a #

toList :: ListZerem r Identity a -> [a] #

null :: ListZerem r Identity a -> Bool #

length :: ListZerem r Identity a -> Int #

elem :: Eq a => a -> ListZerem r Identity a -> Bool #

maximum :: Ord a => ListZerem r Identity a -> a #

minimum :: Ord a => ListZerem r Identity a -> a #

sum :: Num a => ListZerem r Identity a -> a #

product :: Num a => ListZerem r Identity a -> a #

Traversable (ListZerem () Identity) Source # 
Instance details

Defined in Zerem

Methods

traverse :: Applicative f => (a -> f b) -> ListZerem () Identity a -> f (ListZerem () Identity b) #

sequenceA :: Applicative f => ListZerem () Identity (f a) -> f (ListZerem () Identity a) #

mapM :: Monad m => (a -> m b) -> ListZerem () Identity a -> m (ListZerem () Identity b) #

sequence :: Monad m => ListZerem () Identity (m a) -> m (ListZerem () Identity a) #

Monad m => Alternative (ListZerem () m) Source # 
Instance details

Defined in Zerem

Methods

empty :: ListZerem () m a #

(<|>) :: ListZerem () m a -> ListZerem () m a -> ListZerem () m a #

some :: ListZerem () m a -> ListZerem () m [a] #

many :: ListZerem () m a -> ListZerem () m [a] #

Monad m => Applicative (ListZerem () m) Source # 
Instance details

Defined in Zerem

Methods

pure :: a -> ListZerem () m a #

(<*>) :: ListZerem () m (a -> b) -> ListZerem () m a -> ListZerem () m b #

liftA2 :: (a -> b -> c) -> ListZerem () m a -> ListZerem () m b -> ListZerem () m c #

(*>) :: ListZerem () m a -> ListZerem () m b -> ListZerem () m b #

(<*) :: ListZerem () m a -> ListZerem () m b -> ListZerem () m a #

Functor m => Functor (ListZerem r m) Source # 
Instance details

Defined in Zerem

Methods

fmap :: (a -> b) -> ListZerem r m a -> ListZerem r m b #

(<$) :: a -> ListZerem r m b -> ListZerem r m a #

Monad m => Monad (ListZerem () m) Source # 
Instance details

Defined in Zerem

Methods

(>>=) :: ListZerem () m a -> (a -> ListZerem () m b) -> ListZerem () m b #

(>>) :: ListZerem () m a -> ListZerem () m b -> ListZerem () m b #

return :: a -> ListZerem () m a #

Monad m => MonadPlus (ListZerem () m) Source # 
Instance details

Defined in Zerem

Methods

mzero :: ListZerem () m a #

mplus :: ListZerem () m a -> ListZerem () m a -> ListZerem () m a #

Comonad (ListZerem Void Identity) Source # 
Instance details

Defined in Zerem

Monad m => MonadLogic (ListZerem () m) Source # 
Instance details

Defined in Zerem

Methods

msplit :: ListZerem () m a -> ListZerem () m (Maybe (a, ListZerem () m a))

interleave :: ListZerem () m a -> ListZerem () m a -> ListZerem () m a

(>>-) :: ListZerem () m a -> (a -> ListZerem () m b) -> ListZerem () m b

once :: ListZerem () m a -> ListZerem () m a

lnot :: ListZerem () m a -> ListZerem () m ()

ifte :: ListZerem () m a -> (a -> ListZerem () m b) -> ListZerem () m b -> ListZerem () m b

newtype Pipe u v f g m p a b Source #

Constructors

Pipe 

Fields

Instances

Instances details
ProfunctorFunctor (Pipe u v f g m :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # 
Instance details

Defined in Zerem

Methods

promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> Pipe u v f g m p :-> Pipe u v f g m q

Category p => Category (Pipe u u f f m p :: Type -> Type -> Type) Source # 
Instance details

Defined in Zerem

Methods

id :: forall (a :: k). Pipe u u f f m p a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Pipe u u f f m p b c -> Pipe u u f f m p a b -> Pipe u u f f m p a c #

ProfunctorMonad (Pipe Void Void (,) (,) Identity) Source # 
Instance details

Defined in Zerem

Methods

proreturn :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> Pipe Void Void (,) (,) Identity p

projoin :: forall (p :: Type -> Type -> Type). Profunctor p => Pipe Void Void (,) (,) Identity (Pipe Void Void (,) (,) Identity p) :-> Pipe Void Void (,) (,) Identity p

(Profunctor p, Bifunctor g, Functor m) => Choice (Pipe u v (,) g m p) Source # 
Instance details

Defined in Zerem

Methods

left' :: Pipe u v (,) g m p a b -> Pipe u v (,) g m p (Either a c) (Either b c)

right' :: Pipe u v (,) g m p a b -> Pipe u v (,) g m p (Either c a) (Either c b)

(Profunctor p, Bifunctor f, Bifunctor g, Functor m) => Profunctor (Pipe u v f g m p) Source # 
Instance details

Defined in Zerem

Methods

dimap :: (a -> b) -> (c -> d) -> Pipe u v f g m p b c -> Pipe u v f g m p a d

lmap :: (a -> b) -> Pipe u v f g m p b c -> Pipe u v f g m p a c

rmap :: (b -> c) -> Pipe u v f g m p a b -> Pipe u v f g m p a c

(#.) :: forall a b c q. Coercible c b => q b c -> Pipe u v f g m p a b -> Pipe u v f g m p a c

(.#) :: forall a b c q. Coercible b a => Pipe u v f g m p b c -> q a b -> Pipe u v f g m p a c

(Profunctor p, Bifunctor g, Functor m) => Functor (Pipe u v f g m p a) Source # 
Instance details

Defined in Zerem

Methods

fmap :: (a0 -> b) -> Pipe u v f g m p a a0 -> Pipe u v f g m p a b #

(<$) :: a0 -> Pipe u v f g m p a b -> Pipe u v f g m p a a0 #

Mapping

map :: (Bifunctor f, Functor m) => (a -> b) -> Zerem (f a) m r -> Zerem (f b) m r Source #

maps :: Functor m => (forall x. f x -> g x) -> Zerem f m r -> Zerem g m r Source #

mapM :: (Bitraversable f, Monad m) => (a -> m b) -> Zerem (f a) m r -> Zerem (f b) m r Source #

mapsM :: Monad m => (forall x. f x -> m (g x)) -> Zerem f m r -> Zerem g m r Source #

flatLift :: Monad m => Zerem f m (m r) -> Zerem f m r Source #

flatMapLift :: Monad m => (r -> m r') -> Zerem f m r -> Zerem f m r' Source #

(>>^) :: Monad m => Zerem f m r -> (r -> m r') -> Zerem f m r' Source #

hoistAny :: (forall x. m x -> n x) -> Zerem f m r -> Zerem f n r Source #

Folding

runZerem :: Monad m => Zerem m m r -> m r Source #

runZerem_ :: Monad m => Zerem m m r -> m () Source #

map_ :: (Comonad f, Monad m) => Zerem f m r -> m r Source #

maps_ :: Monad m => (forall x. f x -> x) -> Zerem f m r -> m r Source #

mapM_ :: (Bitraversable f, Comonad (f b), Monad m) => (a -> m b) -> Zerem (f a) m r -> m r Source #

mapsM_ :: Monad m => (forall x. f x -> m x) -> Zerem f m r -> m r Source #

foldr :: Monad m => (a -> b -> b) -> (r -> b) -> Zerem ((,) a) m r -> m b Source #

foldr_ :: Monad m => (a -> b -> b) -> b -> Zerem ((,) a) m r -> m b Source #

foldrM :: Monad m => (a -> b -> m b) -> (r -> m b) -> Zerem ((,) a) m r -> m b Source #

foldrM_ :: Monad m => (a -> b -> m b) -> m b -> Zerem ((,) a) m r -> m b Source #

foldl :: Monad m => (b -> a -> b) -> b -> (b -> r -> b') -> Zerem ((,) a) m r -> m b' Source #

foldl_ :: Monad m => (b -> a -> b) -> b -> Zerem ((,) a) m r -> m b Source #

foldlM :: Monad m => (b -> a -> m b) -> m b -> (b -> r -> m b') -> Zerem ((,) a) m r -> m b' Source #

foldlM_ :: Monad m => (b -> a -> m b) -> m b -> Zerem ((,) a) m r -> m b Source #

Scanning

scanl :: (Functor m, Functor g) => (a -> x -> g x) -> x -> (r -> x -> x') -> Zerem ((,) a) m r -> Zerem g m x' Source #

scanl_ :: (Functor m, Functor g) => (a -> x -> g x) -> x -> Zerem ((,) a) m r -> Zerem g m x Source #

scansl :: (Functor f, Functor m) => (forall s. f (s, x) -> g (s, x)) -> x -> (r -> x -> x') -> Zerem f m r -> Zerem g m x' Source #

scansl_ :: (Functor f, Functor m) => (forall s. f (s, x) -> g (s, x)) -> x -> Zerem f m r -> Zerem g m x Source #

Filtering

scanMaybel :: Functor m => (a -> x -> (Maybe b, x)) -> x -> (r -> x -> x') -> Zerem ((,) a) m r -> Zerem ((,) b) m x' Source #

scanMaybel_ :: Functor m => (a -> x -> (Maybe b, x)) -> x -> Zerem ((,) a) m r -> Zerem ((,) b) m x Source #

catMaybes :: Functor m => Zerem ((,) (Maybe a)) m r -> Zerem ((,) a) m r Source #

mapMaybe :: Functor m => (a -> Maybe b) -> Zerem ((,) a) m r -> Zerem ((,) b) m r Source #

concat :: Applicative m => Zerem ((,) [a]) m r -> Zerem ((,) a) m r Source #

concatMap :: Applicative m => (a -> [b]) -> Zerem ((,) a) m r -> Zerem ((,) b) m r Source #

filter :: Functor m => (a -> Bool) -> Zerem ((,) a) m r -> Zerem ((,) a) m r Source #

take :: (Functor f, Applicative m) => Int -> Zerem f m r -> Zerem f m () Source #

drop :: (Comonad f, Functor m) => Int -> Zerem f m r -> Zerem f m r Source #

Generating

yield :: Applicative m => a -> Zerem ((,) a) m () Source #

yieldMany :: (Foldable f, Applicative m) => f a -> Zerem ((,) a) m () Source #

yieldM :: Applicative m => m a -> Zerem ((,) a) m () Source #

yieldManyM :: (Foldable f, Applicative m) => f (m a) -> Zerem ((,) a) m () Source #

concatStream :: (Functor m, Functor g) => (s -> m (Step s g u)) -> Zerem ((,) s) m r -> Zerem g m r Source #

mtimes :: (Monad m, Functor f) => Int -> Zerem f m r -> Zerem f m () Source #