| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Incipit.Full
Description
A Prelude for Polysemy projects, reexporting names and modules from several basic libraries.
Synopsis
- module IncipitCore
- type Mask = Scoped_ RestoreMask
- data Queue d (a :: Type -> Type) b
- data QueueResult d
- data Race (a :: Type -> Type) b
- subscribe :: forall e (r :: EffectRow). Member (Scoped_ (Consume e)) r => InterpreterFor (Consume e) r
- data Events e (a :: Type -> Type) b
- publish :: forall e (r :: EffectRow). Member (Events e) r => e -> Sem r ()
- consume :: forall e (r :: EffectRow). Member (Consume e) r => Sem r e
- type UninterruptibleMask = Scoped_ RestoreMask
- data Sync d (a :: Type -> Type) b
- type ScopedSync a = Scoped_ (Sync a)
- runConc :: Sem ConcStack a -> IO a
- type EventConsumer e = Scoped_ (Consume e)
- data Log (a :: Type -> Type) b
- data DataLog a (b :: Type -> Type) c
- module Polysemy.Resume
- class TimeUnit u
- data Time time date (a :: Type -> Type) b
Documentation
module IncipitCore
type Mask = Scoped_ RestoreMask #
The scoped masking effect.
data Queue d (a :: Type -> Type) b #
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
data QueueResult d #
Encodes failure reasons for queues.
For documentation on the constructors, see the module Polysemy.Conc.Data.QueueResult.
import qualified Polysemy.Conc.Data.QueueResult as QueueResult
Instances
data Race (a :: Type -> Type) b #
Abstract the concept of running two programs concurrently, aborting the other when one terminates.
Timeout is a simpler variant, where one thread just sleeps for a given interval.
subscribe :: forall e (r :: EffectRow). Member (Scoped_ (Consume e)) r => InterpreterFor (Consume e) r #
Create a new scope for Events, causing the nested program to get its own copy of the event stream.
To be used with interpretEventsChan.
consume :: forall e (r :: EffectRow). Member (Consume e) r => Sem r e #
Consume one event emitted by Events.
type UninterruptibleMask = Scoped_ RestoreMask #
The scoped uninterruptible masking effect.
data Sync d (a :: Type -> Type) b #
Abstracts an MVar.
For documentation on the constructors, see the module Polysemy.Conc.Effect.Sync.
import Polysemy.Conc (Sync) import qualified Polysemy.Conc.Effect.Sync as Sync prog :: Member (Sync Int) r => Sem r Int prog = do Sync.putTry 5 Sync.takeBlock
type ScopedSync a = Scoped_ (Sync a) #
Convenience alias.
runConc :: Sem ConcStack a -> IO a #
Interprets UninterruptibleMask, Mask and Race in terms of and runs the entire rest of the
stack.Final IO
type EventConsumer e = Scoped_ (Consume e) #
Convenience alias for the consumer effect.
data Log (a :: Type -> Type) b #
The default high-level effect for simple text messages. To be used with the severity constructors:
import qualified Polysemy.Log as Log prog = do Log.debug "debugging…" Log.warn "warning!"
Interpreters should preprocess and relay the message to DataLog.
module Polysemy.Resume
Types that represent an amount of time that can be converted to each other.
The methods are internal, the API function is convert.
Minimal complete definition
Instances
| TimeUnit Days | |
Defined in Polysemy.Time.Data.TimeUnit | |
| TimeUnit Hours | |
Defined in Polysemy.Time.Data.TimeUnit | |
| TimeUnit MicroSeconds | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: MicroSeconds -> NanoSeconds # fromNanos :: NanoSeconds -> MicroSeconds # | |
| TimeUnit MilliSeconds | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: MilliSeconds -> NanoSeconds # fromNanos :: NanoSeconds -> MilliSeconds # | |
| TimeUnit Minutes | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: Minutes -> NanoSeconds # fromNanos :: NanoSeconds -> Minutes # | |
| TimeUnit NanoSeconds | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: NanoSeconds -> NanoSeconds # fromNanos :: NanoSeconds -> NanoSeconds # | |
| TimeUnit Seconds | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: Seconds -> NanoSeconds # fromNanos :: NanoSeconds -> Seconds # | |
| TimeUnit Weeks | |
Defined in Polysemy.Time.Data.TimeUnit | |
| TimeUnit DiffTime | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: DiffTime -> NanoSeconds # fromNanos :: NanoSeconds -> DiffTime # | |
| TimeUnit NominalDiffTime | |
Defined in Polysemy.Time.Data.TimeUnit Methods nanos :: NanoSeconds # toNanos :: NominalDiffTime -> NanoSeconds # fromNanos :: NanoSeconds -> NominalDiffTime # | |