CodeVetter · Repo Unpack · Behavior traces
gcanti/fp-ts
Eight source walks describe consumer and maintainer behavior without executing it. The primary consumer paths cover optional-value extraction, JSON decoding, asynchronous failures, concurrent and sequential traversal, cleanup, and mutable references. The package path follows compilation through generated artifact assembly. Each trace identifies execution order and the branch that changes subsequent work.
- Getting-started flow: inverse(2) constructs Some(0.5), pipe invokes Option.map to construct Some(50), then getOrElse extracts 50; inverse(0) produces None, skips map's callback, and evaluates the fallback.
- JSON flow: Json.parse → Either.tryCatch → JSON.parse → right on success or left(identity(error)) on throw; a subsequent Either.map runs only for Right.
- Promise flow: tryCatchK captures arguments and constructs tryCatch; invoking the returned TaskEither calls f, awaits its Promise, and converts rejection or synchronous throw to Left; flatMap then preserves Left or invokes the Right continuation.
- Parallel traversal: TaskEither.traverseReadonlyArrayWithIndex chooses ApT for empty input; otherwise Task traversal starts every indexed thunk through Promise.all, then Either traversal collects Rights or selects the first Left in input order.
- Sequential traversal: the Seq helper invokes f(0,head) first, chains each remaining element through a Promise reduction, appends successful values, and skips later f invocations once the accumulated result is Left.
- Resource flow: bracket delegates to bracketW; failed acquisition skips use/release, successful acquisition executes use, then release receives its resolved Either; release Left overrides the use result, while successful release restores that result.
- Reference flow: newIORef(1) returns an allocation thunk; IO.flatMap invokes it, ref.write(2) returns a mutation thunk, the next IO.flatMap executes that write, and ref.read observes the updated private value.
- Build flow: npm's prebuild cleans dist, two tsc configurations emit JavaScript/declarations, then main runs copyPackageJson → copyFiles → makeModules → fixHKT('es6') → fixHKT('lib'); run invokes the assembled effect and sets the process exit code.