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

Function safeDivide

test/koka-samples.spec.ts:58–61  ·  view source on GitHub ↗
(x: number, y: number)

Source from the content-addressed store, hash-verified

56const raise: EffectFactory<Raise> = effect("raise");
57
58const safeDivide = (x: number, y: number) =>
59 effected(function* () {
60 return y === 0 ? yield* raise("Division by zero") : x / y;
61 });
62
63type Maybe<T> = { _tag: "Just"; value: T } | { _tag: "Nothing" };
64const just = <T>(value: T): Maybe<T> => ({ _tag: "Just", value });

Callers 4

effected.spec.tsFile · 0.70
raiseConst1Function · 0.70
raiseConst2Function · 0.70

Calls 1

effectedFunction · 0.90

Tested by

no test coverage detected