parent
037837b551
commit
0e4a111f81
1714 changed files with 20803 additions and 11751 deletions
20
packages/backend/src/prelude/maybe.ts
Normal file
20
packages/backend/src/prelude/maybe.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
export interface IMaybe<T> {
|
||||
isJust(): this is IJust<T>;
|
||||
}
|
||||
|
||||
export interface IJust<T> extends IMaybe<T> {
|
||||
get(): T;
|
||||
}
|
||||
|
||||
export function just<T>(value: T): IJust<T> {
|
||||
return {
|
||||
isJust: () => true,
|
||||
get: () => value
|
||||
};
|
||||
}
|
||||
|
||||
export function nothing<T>(): IMaybe<T> {
|
||||
return {
|
||||
isJust: () => false,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue