4 ms·
Is there a technical reason why algebraic types and pattern matching are only found in functional languages, or is it an accident of history?
by andreasvc 13y ago
Is there a technical reason why algebraic types and pattern matching are only found in functional languages, or is it an accident of history?
- tsuyoshi 13y agoIt's sort of an accident: the inventor of ML (which SML, OCaml, and F# are descended from, and Haskell has liberally borrowed from) is the "Milner" in Hindley-Milner type checking, and algebraic types are one of the things that make Hindley-Milner useful. Anyone who's used the object-oriented part of OCaml can tell you that inheritance can mix with Hindley-Milner awkwardly... but I'm not sure that really means algebraic types and pattern matching couldn't be integrated into Java, Python, or whatever somehow. For all I know, maybe it's already on the way into C++...