ki-effectful-0.1.1.0: Adaptation of the ki library for the effectful ecosystem.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Effectful.Ki

Synopsis

Effect

Handlers

Core API

data Scope #

A scope.

👉 Details

Expand
  • A scope delimits the lifetime of all threads created within it.
  • A scope is only valid during the callback provided to scoped.
  • The thread that creates a scope is considered the parent of all threads created within it.
  • All threads created within a scope can be awaited together (see awaitAll).
  • All threads created within a scope are terminated when the scope closes.

data Thread a #

A thread.

👉 Details

Expand
  • A thread's lifetime is delimited by the scope in which it was created.
  • The thread that creates a scope is considered the parent of all threads created within it.
  • If an exception is raised in a child thread, the child either propagates the exception to its parent (see fork), or returns the exception as a value (see forkTry).
  • All threads created within a scope are terminated when the scope closes.

Instances

Instances details
Functor Thread 
Instance details

Defined in Ki.Internal.Thread

Methods

fmap :: (a -> b) -> Thread a -> Thread b #

(<$) :: a -> Thread b -> Thread a #

Eq (Thread a) 
Instance details

Defined in Ki.Internal.Thread

Methods

(==) :: Thread a -> Thread a -> Bool #

(/=) :: Thread a -> Thread a -> Bool #

Ord (Thread a) 
Instance details

Defined in Ki.Internal.Thread

Methods

compare :: Thread a -> Thread a -> Ordering #

(<) :: Thread a -> Thread a -> Bool #

(<=) :: Thread a -> Thread a -> Bool #

(>) :: Thread a -> Thread a -> Bool #

(>=) :: Thread a -> Thread a -> Bool #

max :: Thread a -> Thread a -> Thread a #

min :: Thread a -> Thread a -> Thread a #

scoped :: StructuredConcurrency :> es => (Scope -> Eff es a) -> Eff es a Source #

fork :: StructuredConcurrency :> es => Scope -> Eff es a -> Eff es (Thread a) Source #

forkTry :: Exception e => StructuredConcurrency :> es => Scope -> Eff es a -> Eff es (Thread (Either e a)) Source #

await :: Thread a -> STM a #

Wait for a thread to terminate.

awaitAll :: Scope -> STM () #

Wait until all threads created within a scope terminate.

Extended API

Thread options

data ThreadOptions #

affinity

The affinity of a thread. A thread can be unbound, bound to a specific capability, or bound to a specific OS thread.

Default: Unbound

allocationLimit

The maximum number of bytes a thread may allocate before it is delivered an AllocationLimitExceeded exception. If caught, the thread is allowed to allocate an additional 100kb (tunable with +RTS -xq) to perform any necessary cleanup actions; if exceeded, the thread is delivered another.

Default: Nothing (no limit)

label

The label of a thread, visible in the event log (+RTS -l).

Default: "" (no label)

maskingState

The masking state a thread is created in. To unmask, use unsafeUnmask.

Default: Unmasked

Instances

Instances details
Show ThreadOptions 
Instance details

Defined in Ki.Internal.Thread

Eq ThreadOptions 
Instance details

Defined in Ki.Internal.Thread

data ThreadAffinity #

What, if anything, a thread is bound to.

Constructors

Unbound

Unbound.

Capability Int

Bound to a capability.

OsThread

Bound to an OS thread.

Instances

Instances details
Show ThreadAffinity 
Instance details

Defined in Ki.Internal.Thread

Eq ThreadAffinity 
Instance details

Defined in Ki.Internal.Thread

Byte count

data ByteCount #

A number of bytes.

Instances

Instances details
Show ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

Eq ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

Ord ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

kilobytes :: Natural -> ByteCount #

A number of kilobytes.

megabytes :: Natural -> ByteCount #

A number of megabytes.

STM re-export