Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- loopOr :: Member (Queue d) r => Sem r Bool -> (d -> Sem r Bool) -> Sem r ()
- loop :: Member (Queue d) r => (d -> Sem r ()) -> Sem r ()
- data Queue d :: Effect
- read :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d)
- tryRead :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d)
- readTimeout :: forall d r t. (MemberWithError (Queue d) r, TimeUnit t) => t -> Sem r (QueueResult d)
- peek :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d)
- tryPeek :: forall d r. MemberWithError (Queue d) r => Sem r (QueueResult d)
- write :: forall d r. MemberWithError (Queue d) r => d -> Sem r ()
- tryWrite :: forall d r. MemberWithError (Queue d) r => d -> Sem r (QueueResult ())
- writeTimeout :: forall d r t. (MemberWithError (Queue d) r, TimeUnit t) => t -> d -> Sem r (QueueResult ())
- closed :: forall d r. MemberWithError (Queue d) r => Sem r Bool
- close :: forall d r. MemberWithError (Queue d) r => Sem r ()
Documentation
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
type DefiningModule Queue Source # | |
Defined in 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 #
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 #