polysemy-conc-0.3.0.0: Polysemy Effects for Concurrency
Safe HaskellNone
LanguageHaskell2010

Polysemy.Conc.Queue

Description

 
Synopsis

Documentation

loopOr :: Member (Queue d) r => Sem r Bool -> (d -> Sem r Bool) -> Sem r () Source #

Read from a Queue repeatedly until it is closed.

When an element is received, call action and recurse if it returns True. When no element is available, evaluate na and recurse if it returns True.

loop :: Member (Queue d) r => (d -> Sem r ()) -> Sem r () Source #

Read from a Queue repeatedly until it is closed.

When an element is received, call action and recurse.

data Queue d :: Effect Source #

Abstracts queues like TBQueue.

For documentation on the constructors, see the module Polysemy.Conc.Data.Queue.

import Polysemy.Conc (Queue, QueueResult)
import Polysemy.Conc.Effect.Queue as Queue

prog :: Member (Queue Int) r => Sem r (QueueResult Int)
prog = do
  Queue.write 5
  Queue.write 10
  Queue.read >>= \case
    QueueResult.Success i -> fmap (i +) <$> Queue.read
    r -> pure r

Instances

Instances details
type DefiningModule Queue Source # 
Instance details

Defined in Polysemy.Conc.Effect.Queue

type DefiningModule Queue = "Polysemy.Conc.Effect.Queue"

read :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d) Source #

tryRead :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d) Source #

readTimeout :: forall d r t. (MemberWithError (Queue d) r, TimeUnit t) => t -> Sem r (QueueResult d) Source #

peek :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d) Source #

tryPeek :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d) Source #

write :: forall d r. MemberWithError (Queue d) r => d -> Sem r () Source #

tryWrite :: forall d r. MemberWithError (Queue d) r => d -> Sem r (QueueResult ()) Source #

writeTimeout :: forall d r t. (MemberWithError (Queue d) r, TimeUnit t) => t -> d -> Sem r (QueueResult ()) Source #

closed :: forall d r. MemberWithError (Queue d) r => Sem r Bool Source #

close :: forall d r. MemberWithError (Queue d) r => Sem r () Source #