Update to use Either correctly

This commit is contained in:
Eric Rumsey 2025-05-27 13:31:22 -05:00
parent 83a0c1cf31
commit 52e00c3f38

View File

@ -2,14 +2,11 @@ import { type Either, left, right } from './either'
import { none, type Option, some } from './option' import { none, type Option, some } from './option'
// Pipe function for composition // Pipe function for composition
export const pipe = <A, B, C>( export const pipe = <A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C =>
a: A, bc(ab(a))
ab: (a: A) => B,
bc: (b: B) => C,
): C => bc(ab(a))
// TryCatch helper using Either // TryCatch helper using Either
export const tryCatch = <A>(f: () => A): Either<Error, A> => { export const tryCatch = <A>(f: () => A): Either<A, Error> => {
try { try {
return right(f()) return right(f())
} catch (e) { } catch (e) {