3 ms·
I have some noob questions that I don't know how to ask: What, if any, is the relationship between type systems and pattern matching? Does structural typing r
by specialist 7y ago
I have some noob questions that I don't know how to ask:
What, if any, is the relationship between type systems and pattern matching?
Does structural typing reduce the need for instanceof style tests?
So if a language uses structure typing, is pattern matching not useful, applicable?
--
Thanks for humoring me. I'm mostly a Java programmer, self taught, no CS background. I've been reading wiki articles about type systems, trying to figure out what it all means, how to get started. Inference, structural vs nominal, linear types... But, honestly, my eyes glaze over pretty quickly.
Am planning on powering thru Appel's 2002 book, especially implementing the type system, but we'll see how far I get.
- aidenn0 7y agoPattern matching can be used in typed and untyped languages. One reason it's more strongly associated with typed languages is that the type system can easily check a pattern match to prove various things about it (e.g. that the set of pattern matches covers all possible inputs). Note that there is no technical reason an if/then/else construct couldn't be used instead, but the shape of the data is front and center with a pattern match.