Skip to content

Instantly share code, notes, and snippets.

@chuckadams
Created May 21, 2020 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuckadams/8efb8f1f75836a68609ea4b5541c1efb to your computer and use it in GitHub Desktop.
Save chuckadams/8efb8f1f75836a68609ea4b5541c1efb to your computer and use it in GitHub Desktop.
dependent types in typescript
type Maybe<a> = { val: a, tag = "some" } | { tag: "none" }
function isSome<A, Ma: Maybe<a>>(m: Ma): Ma["val"] is A {
return m.tag == "some";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment