Compare commits
2 Commits
baab2e75d9
...
e220b7930c
| Author | SHA1 | Date | |
|---|---|---|---|
| e220b7930c | |||
| b53558e2d1 |
@ -22,7 +22,7 @@ export const eitherChain =
|
|||||||
fa._tag === 'Right' ? f(fa.right) : fa
|
fa._tag === 'Right' ? f(fa.right) : fa
|
||||||
|
|
||||||
export const fold =
|
export const fold =
|
||||||
<A, B, E>(onLeft: (e: E) => B, onRight: (a: A) => B) =>
|
<A, E, B>(onLeft: (e: E) => B, onRight: (a: A) => B) =>
|
||||||
(fa: Either<A, E>): B =>
|
(fa: Either<A, E>): B =>
|
||||||
fa._tag === 'Left' ? onLeft(fa.left) : onRight(fa.right)
|
fa._tag === 'Left' ? onLeft(fa.left) : onRight(fa.right)
|
||||||
|
|
||||||
|
|||||||
@ -174,5 +174,11 @@ export const tryCatch = <A>(f: () => A): Either<A, Error> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Tag<T> {
|
||||||
|
readonly _tag: T
|
||||||
|
}
|
||||||
|
|
||||||
|
export const hasTag = (x: string) => (y: Tag<string>) => x === y._tag
|
||||||
|
|
||||||
export const fromNullable = <A>(a: A | null | undefined): Option<A> =>
|
export const fromNullable = <A>(a: A | null | undefined): Option<A> =>
|
||||||
a == null ? none : some(a)
|
a == null ? none : some(a)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user