Expand description
Types that hold exactly one value which can be extracted.
Extract is the inverse of Deferrable: where
Deferrable constructs a value lazily from a thunk, Extract forces/extracts
the inner value. For types whose brand implements Extract (e.g.,
ThunkBrand), extract(defer(|| x)) == x
forms a round-trip. Note that Extract is a brand-level trait (implemented
by ThunkBrand), while Deferrable is a value-level trait (implemented by
concrete types like Thunk).
This trait is used by Free::evaluate to
execute the effects in a Free monad.
§Examples
use fp_library::{
brands::*,
functions::*,
types::*,
};
let thunk = Thunk::new(|| 42);
assert_eq!(extract::<ThunkBrand, _>(thunk), 42);Traits§
- Extract
- A type containing exactly one extractable value, providing a natural
transformation
F ~> Id.
Functions§
- extract
- Extracts the inner value.