id_effect_fp
Functional-programming toolkit for id_effect — maintenance tier
(ADR 0010): kept building and tested, not on the core
roadmap.
These modules lived in the core id_effect crate until 0.6. The core runtime does not need them,
so they moved here together with their im and Rayon-backed bulk operations:
| Module | What | Formerly |
|---|---|---|
algebra |
Semigroup, Monoid, Functor, Applicative, Monad, Bifunctor, Contravariant, Selective, Foldable, Traversable, FreeAp |
id_effect::algebra |
collections |
Persistent EffectHashMap / EffectHashSet / EffectSortedMap / EffectSortedSet / EffectVector / RedBlackTree (backed by im), MutableList, MutableQueue, ChunkBuilder, Trie |
id_effect::collections |
stm |
TRef, TMap, TQueue, TSemaphore, Stm, commit / atomically |
id_effect::stm |
foundation |
Unit, Never, Iso, products, coproducts, function, option_ |
id_effect::foundation::* |
result, reader, thunk |
Pure Result combinators, the Reader monad, one-shot thunks |
id_effect::kernel::{result, reader, thunk} |
Either, Pipe, Predicate, MutableRef and func stay in id_effect::foundation.
Example
use Exit;
use ;
// STM: transactional reference cells, committed as a 0.7-kernel `Effect`.
let counter = commit.block_on.into_result.expect;
commit.block_on.into_result.expect;
assert_eq!;
// Persistent collections: updates return new maps; the old one is untouched.
let a = set;
let b = set;
assert_eq!;
// Algebra: combine values through type-class traits.
assert_eq!;
assert_eq!;
Examples
STM examples: 077–086; algebra examples: 090–092.
STM retry
commit runs on the 0.7 kernel. A transaction that retries
(Stm::retry, Stm::check(false), TQueue::take on an empty queue, TSemaphore::acquire at
zero) parks its fiber on the wait lists of the TRefs it read, and the next commit that writes
one of them wakes it (Effect.ts STM.retry). Nothing spins and no thread is blocked; an
interrupted waiter is removed from every wait list.