The history of the idea goes back at least to
Tony Hoare's "record class discriminators" from the mid-1960s. However, practical type systems including it as a feature are much more recent. Typed Scheme, a type system for
Scheme developed by Sam Tobin-Hochstadt and first published in 2008, was the first type system to include occurrence typing. Its successor, Typed Racket (a dialect of
Racket), is also based on occurrence typing. Shortly after Typed Scheme, David J. Pearce independently reinvented flow-typing in
Whiley. Typed JavaScript observed that in "scripting" languages, flow-typing depends on more than conditional predicates; it also depends on state and control flow. This style has since been adopted in languages like
Ceylon,
TypeScript and
Facebook Flow. There are also a few languages that don't have
union types but do have
nullable types, that have a limited form of this feature that only applies to nullable types, such as
C#,
Kotlin, and Lobster. ==Alternatives==