Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Fresh uniq :: Effect where
- fresh :: Eff (Fresh uniq) m => m uniq
- freshToIO :: Eff (Embed IO) m => FreshToIOC m a -> m a
- runFreshEnumIO :: forall uniq m a. (Enum uniq, Eff (Embed IO) m) => InterpretReifiedC (Fresh uniq) m a -> m a
- runFreshEnum :: forall uniq m a p. (Enum uniq, Threaders '[StateThreads] m p, Carrier m) => FreshEnumC uniq m a -> m a
- runFreshEnumIOSimple :: forall uniq m a p. (Enum uniq, Eff (Embed IO) m, Threaders '[ReaderThreads] m p) => InterpretSimpleC (Fresh uniq) m a -> m a
- class (forall s. Threads (StateT s) p) => StateThreads p
- type FreshToIOC = InterpretC FreshToIOH (Fresh Unique)
- type FreshEnumC uniq = CompositionC '[ReinterpretC FreshEnumH (Fresh uniq) '[State uniq], StateC uniq]
Effects
data Fresh uniq :: Effect where Source #
An effect for creating unique objects which may be used as references,
a la Unique
. Polymorphic code making use of Fresh
is expected
to place constraints upon uniq
as necessary.
Any interpreter for Fresh
has the responsibilty of ensuring
that any call to fresh
produces an object that never
compares equal to an object produced by a previous call to fresh
.
Actions
Interpretations
runFreshEnumIO :: forall uniq m a. (Enum uniq, Eff (Embed IO) m) => InterpretReifiedC (Fresh uniq) m a -> m a Source #
Run a Fresh
effect through atomic operations in IO
by specifying an Enum
to be used as the type of unique objects.
This is a safe variant of runFreshEnum
.
This has a higher-rank type, as it makes use of InterpretReifiedC
.
This makes runFreshEnumIO
very difficult to use partially applied.
In particular, it can't be composed using
..
If performance is secondary, consider using the slower
runFreshEnumIOSimple
, which doesn't have a higher-rank type.
Unsafe interpretations
runFreshEnum :: forall uniq m a p. (Enum uniq, Threaders '[StateThreads] m p, Carrier m) => FreshEnumC uniq m a -> m a Source #
Run a Fresh
effect purely by specifying an Enum
to be used as the
type of unique objects.
Beware: This is safe only if:
- This is run after all interpreters which may revert local state
or produce multiple, inconsistent instances of local state.
This includes interpreters that may backtrack or produce multiple results
(such as
runError
orrunNonDet
). - You don't use any interpreter which may cause the final monad
to revert local state or produce multiple, inconsistent instances
of local state. This includes
errorToIO
andasyncToIO
.
Prefer freshToIO
or runFreshEnumIO
whenever possible.
Derivs
(FreshEnumC
uniq m) =Fresh
uniq ':Derivs
m
Prims
(FreshEnumC
uniq m) =Prims
m
Simple variants of interpretations
runFreshEnumIOSimple :: forall uniq m a p. (Enum uniq, Eff (Embed IO) m, Threaders '[ReaderThreads] m p) => InterpretSimpleC (Fresh uniq) m a -> m a Source #
Run a Fresh
effect though atomic operations in IO
by specifying an Enum
to be used as the type of unique objects.
This is a less performant version of runFreshEnumIO
that doesn't have
a higher-rank type, making it much easier to use partially applied.
Threading constraints
class (forall s. Threads (StateT s) p) => StateThreads p Source #
StateThreads
accepts the following primitive effects:
Regional
s
Optional
s
(whens
is a functor)BaseControl
b
ListenPrim
o
(wheno
is aMonoid
)WriterPrim
o
(wheno
is aMonoid
)ReaderPrim
i
Mask
Bracket
Fix
Split
Instances
(forall s. Threads (StateT s) p) => StateThreads p Source # | |
Defined in Control.Effect.Internal.State |
Carriers
type FreshToIOC = InterpretC FreshToIOH (Fresh Unique) Source #
type FreshEnumC uniq = CompositionC '[ReinterpretC FreshEnumH (Fresh uniq) '[State uniq], StateC uniq] Source #