3 ms·
I'd extend that one step further unpacking < destructuring < pattern matching < first-class patterns where first-class patterns are increasingly becoming
by tel 13y ago
I'd extend that one step further
unpacking < destructuring < pattern matching < first-class patterns
where first-class patterns are increasingly becoming available in some languages which offer pattern matching (in particular, Haskell will have them soon).
- dkersten 13y agoI did a little googling, but am finding it difficult to find good clear information - do you have any articles where I can read about first-class patterns?
- Tyr42 13y agohttps://ghc.haskell.org/trac/ghc/wiki/ViewPatterns https://ghc.haskell.org/trac/ghc/wiki/ViewPatterns That's the haskell extension. To see a very nice use of them, check out this paper (pdf) http://strictlypositive.org/CJ.pdf http://strictlypositive.org/CJ.pdf
- anaphor 13y agoHow do view patterns make patterns "first-class"? To me that means able to manipulate them as values, I don't see how view patterns allow that, they're just syntactic sugar for case expressions.
- tel 13y agohttp://www.reddit.com/r/haskell/comments/1vpaey/pattern_synonyms_merged_into_ghchead/ http://www.reddit.com/r/haskell/comments/1vpaey/pattern_syno... I spoke too eagerly—the new feature is just named and namespaced patterns. It's a bit of a bump in power, but it's not fully general yet. For true(-ish) first-class patterns take a look at Prisms in the lens package or some of the other first-class pattern libraries.