pipes-fluid-0.6.0.1: Reactively combines Producers so that a value is yielded as soon as possible.

Safe HaskellSafe
LanguageHaskell2010

Pipes.Fluid.Merge

Synopsis

Documentation

data Source #

Differentiates whether a value from either or both producers. In the case of one producer, additional identify if the other producer is live or dead.

Instances
Eq Source # 
Instance details

Defined in Pipes.Fluid.Merge

Methods

(==) :: Source -> Source -> Bool #

(/=) :: Source -> Source -> Bool #

Ord Source # 
Instance details

Defined in Pipes.Fluid.Merge

Show Source # 
Instance details

Defined in Pipes.Fluid.Merge

Generic Source # 
Instance details

Defined in Pipes.Fluid.Merge

Associated Types

type Rep Source :: * -> * #

Methods

from :: Source -> Rep Source x #

to :: Rep Source x -> Source #

type Rep Source # 
Instance details

Defined in Pipes.Fluid.Merge

type Rep Source = D1 (MetaData "Source" "Pipes.Fluid.Merge" "pipes-fluid-0.6.0.1-5J6HnQmFcseA9yBK6VsOGH" False) (C1 (MetaCons "FromBoth" PrefixI False) (U1 :: * -> *) :+: (C1 (MetaCons "FromLeft" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 OtherStatus)) :+: C1 (MetaCons "FromRight" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 OtherStatus))))

data OtherStatus #

The other producer can be live (still yielding values), or dead

Constructors

OtherLive 
OtherDead 
Instances
Eq OtherStatus # 
Instance details

Defined in Pipes.Fluid.Merge

Ord OtherStatus # 
Instance details

Defined in Pipes.Fluid.Merge

Show OtherStatus # 
Instance details

Defined in Pipes.Fluid.Merge

Generic OtherStatus # 
Instance details

Defined in Pipes.Fluid.Merge

Associated Types

type Rep OtherStatus :: * -> * #

type Rep OtherStatus # 
Instance details

Defined in Pipes.Fluid.Merge

type Rep OtherStatus = D1 (MetaData "OtherStatus" "Pipes.Fluid.Merge" "pipes-fluid-0.6.0.1-5J6HnQmFcseA9yBK6VsOGH" False) (C1 (MetaCons "OtherLive" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "OtherDead" PrefixI False) (U1 :: * -> *))

data Merged a b #

Differentiates when only one side is available (due to initial merge values of Nothing) or if two values (one of which may be a previous values) are availabe.

Instances
(Eq a, Eq b) => Eq (Merged a b) # 
Instance details

Defined in Pipes.Fluid.Merge

Methods

(==) :: Merged a b -> Merged a b -> Bool #

(/=) :: Merged a b -> Merged a b -> Bool #

(Ord a, Ord b) => Ord (Merged a b) # 
Instance details

Defined in Pipes.Fluid.Merge

Methods

compare :: Merged a b -> Merged a b -> Ordering #

(<) :: Merged a b -> Merged a b -> Bool #

(<=) :: Merged a b -> Merged a b -> Bool #

(>) :: Merged a b -> Merged a b -> Bool #

(>=) :: Merged a b -> Merged a b -> Bool #

max :: Merged a b -> Merged a b -> Merged a b #

min :: Merged a b -> Merged a b -> Merged a b #

(Show a, Show b) => Show (Merged a b) # 
Instance details

Defined in Pipes.Fluid.Merge

Methods

showsPrec :: Int -> Merged a b -> ShowS #

show :: Merged a b -> String #

showList :: [Merged a b] -> ShowS #

Generic (Merged a b) # 
Instance details

Defined in Pipes.Fluid.Merge

Associated Types

type Rep (Merged a b) :: * -> * #

Methods

from :: Merged a b -> Rep (Merged a b) x #

to :: Rep (Merged a b) x -> Merged a b #

type Rep (Merged a b) # 
Instance details

Defined in Pipes.Fluid.Merge

isBothLive :: Merged x y -> Bool #

This can be used with takeWhile

isLeftLive :: Merged x y -> Bool #

This can be used with takeWhile

isRightLive :: Merged x y -> Bool #

This can be used with takeWhile

isRightDead :: Merged x y -> Bool #

This can be used with takeWhile

isLeftDead :: Merged x y -> Bool #

This can be used with takeWhile

class Merge f where #

Minimal complete definition

merge'

Methods

merge' :: Maybe x -> Maybe y -> f x -> f y -> f (Merged x y) #

Instances
(MonadBaseControl IO m, Forall (Pure m)) => Merge (ImpulseIO m) #

Reactively combines two producers, given initial values to use when the produce hasn't produced anything yet Combine two signals, and returns a signal that emits Either bothfired (Either (leftFired, previousRight) (previousLeft, rightFired)). This creates two threads each time this combinator is used. Warning: This means that the monadic effects are run in isolation from each other so if the monad is something like (StateT s IO), then the state will alternate between the two input producers, which is most likely not what you want. This will be detect as a compile error due to use of Control.Concurrent.Async.Lifted.Safe

Instance details

Defined in Pipes.Fluid.ImpulseIO

Methods

merge' :: Maybe x -> Maybe y -> ImpulseIO m x -> ImpulseIO m y -> ImpulseIO m (Merged x y) #

(Alternative m, Monad m) => Merge (Impulse m) #

Impulseively combines two producers, given initial values to use when the produce hasn't produced anything yet Combine two signals, and returns a signal that emits Either bothfired (Either (leftFired, previousRight) (previousLeft, rightFired)). This only works for Alternative m where failure means there was no effects, eg. STM, or MonadTrans t => t STM. Be careful of monad transformers ExceptT that hides the STM Alternative instance.

Instance details

Defined in Pipes.Fluid.Impulse

Methods

merge' :: Maybe x -> Maybe y -> Impulse m x -> Impulse m y -> Impulse m (Merged x y) #

merge :: Merge f => f x -> f y -> f (Merged x y) #

discreteLeft :: Merged x y -> Maybe x #

Keep only the values originated from the left, replacing other yields with Nothing. This is useful when React is based on STM, since filtering with Producer STM results in larger STM transactions which may result in blocking.

discreteRight :: Merged x y -> Maybe y #

Keep only the values originated from the right, replacing other yields with Nothing. This is useful when React is based on STM, since filtering with Producer STM results in larger STM transactions which may result in blocking.

discreteBoth :: Merged x y -> Maybe (x, y) #

Keep only the values originated from both, replacing other yields with Nothing. This is useful when React is based on STM, since filtering with Producer STM results in larger STM transactions which may result in blocking.

discrete' :: Merged x x -> NonEmpty x #

Keep only the "new" values

discrete :: Semigroup x => Merged x x -> x #

Keep only the "new" values (using semigroup <> when both values were active)

mergeDiscrete' :: (Merge f, Functor f) => f x -> f x -> f (NonEmpty x) #

merge two producers of the same type together.

mergeDiscrete :: (Semigroup x, Merge f, Functor f) => f x -> f x -> f x #

merge two producers of the same type together (using semigroup <> when both values were active)