Skip to content

Instantly share code, notes, and snippets.

@owen-d
Last active May 6, 2019 20:14
Show Gist options
  • Save owen-d/9d098a1177288d8c9203577d52ee7bc9 to your computer and use it in GitHub Desktop.
Save owen-d/9d098a1177288d8c9203577d52ee7bc9 to your computer and use it in GitHub Desktop.
maybe typescript
// This excludes us from trying to use (Maybe null) sensibly.
export type Maybe<T> = T | null
export function isJust<T>(x: Maybe<T>): x is T {
return x !== null
}
export function isNothing<T>(x: Maybe<T>): x is null {
return x === null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment