MCPcopy Create free account
hub / github.com/Snowflyt/tinyeffect / pState

Function pState

test/koka-samples.spec.ts:228–237  ·  view source on GitHub ↗
(init: T)

Source from the content-addressed store, hash-verified

226 );
227
228const pState = <T>(init: T) =>
229 defineHandlerFor<State<T>>().with((self) => {
230 let st = init;
231 return self
232 .andThen((x) => [x, st] as const)
233 .resume("state.get", () => st)
234 .resume("state.set", (x) => {
235 st = x;
236 });
237 });
238
239test("3.4.5. Return Operations", () => {
240 expect(safeDivide(1, 0).with(raiseMaybe).runSync()).toEqual(nothing);

Callers 3

raiseState1Function · 0.85
stateRaiseFunction · 0.85

Calls 4

defineHandlerForFunction · 0.90
withMethod · 0.65
resumeMethod · 0.65
andThenMethod · 0.65

Tested by

no test coverage detected