16 lines
343 B
TypeScript
16 lines
343 B
TypeScript
type Either<T, U> = {
|
|
hasRight: boolean,
|
|
left: T,
|
|
right: U
|
|
};
|
|
|
|
function eitherLeft<T, U>(left: T): Either<T, U> {
|
|
return { hasRight: false, left: left, right: undefined };
|
|
}
|
|
|
|
function eitherRight<T, U>(right: U): Either<T, U> {
|
|
return { hasRight: true, left: undefined, right: right };
|
|
}
|
|
|
|
export { Either, eitherLeft, eitherRight };
|