Skuld.Effects.FreshInt (skuld v0.30.0)
View SourceFreshInt effect — generate monotonically increasing integers.
Zero dependencies. The handler stores a seed value in env state, returns it, and increments. Both test and production handlers use the same counter implementation — deterministic by default, no external library needed.
Production Usage
comp do
id <- FreshInt.fresh_integer()
id
end
|> FreshInt.with_handler()
|> Comp.run!()
#=> 0Test Usage (Deterministic)
comp do
id <- FreshInt.fresh_integer()
id
end
|> FreshInt.with_handler(seed: 100)
|> Comp.run!()
#=> 100 (deterministic, reproducible)
Summary
Functions
@spec with_handler( Skuld.Comp.Types.computation(), keyword() ) :: Skuld.Comp.Types.computation()
Install a FreshInt handler.
Options
:seed— starting integer value (default: 0)