Safe Haskell | Safe-Inferred |
---|---|
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 ()
- readMaybe :: Member (Queue d) r => Sem r (Maybe d)
- tryReadMaybe :: Member (Queue d) r => Sem r (Maybe d)
- data Queue d :: Effect
- module Polysemy.Conc.Data.QueueResult
- module Polysemy.Conc.Data.QueueResult
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