mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 18:22:14 +00:00
22 lines
432 B
TypeScript
22 lines
432 B
TypeScript
import { Result as Either } from 'ts-results-es';
|
|
|
|
|
|
export abstract class Context<Left, Right> {
|
|
private constructor(private _: Either<Left, Right>){}
|
|
|
|
abstract get message(): Left;
|
|
abstract get interaction(): Right;
|
|
|
|
}
|
|
|
|
function safeUnwrap<T>(res: Either<T, T>) {
|
|
return res.val;
|
|
}
|
|
|
|
export function wrap<Left, Right>(
|
|
val: Left|Right,
|
|
fa: (val: Left|Right) => Either<Left, Right>
|
|
) {
|
|
return fa(val);
|
|
}
|