Update to use Either correctly
This commit is contained in:
parent
83a0c1cf31
commit
52e00c3f38
@ -2,14 +2,11 @@ import { type Either, left, right } from './either'
|
||||
import { none, type Option, some } from './option'
|
||||
|
||||
// Pipe function for composition
|
||||
export const pipe = <A, B, C>(
|
||||
a: A,
|
||||
ab: (a: A) => B,
|
||||
bc: (b: B) => C,
|
||||
): C => bc(ab(a))
|
||||
export const pipe = <A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C =>
|
||||
bc(ab(a))
|
||||
|
||||
// TryCatch helper using Either
|
||||
export const tryCatch = <A>(f: () => A): Either<Error, A> => {
|
||||
export const tryCatch = <A>(f: () => A): Either<A, Error> => {
|
||||
try {
|
||||
return right(f())
|
||||
} catch (e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user