export interface IMaybe { isJust(): this is IJust; } export interface IJust extends IMaybe { get(): T; } export function just(value: T): IJust { return { isJust: () => true, get: () => value, }; } export function nothing(): IMaybe { return { isJust: () => false, }; }