4 ms·
Slight bit of pedantry (not to detract from the overall content of your post): dec (n + 1) is not a view pattern, it's an n+k pattern, and Haskellers have mostl
by ezyang 16y ago
Slight bit of pedantry (not to detract from the overall content of your post): dec (n + 1) is not a view pattern, it's an n+k pattern, and Haskellers have mostly decided that they were a bad idea. However, you've gotten the point of real view patterns (foo (someFunc -> x)) spot on: they encourage better data abstraction, which is helpful if you've got an imperative .net library that you want to interface with.
- rlmw 16y agoThanks for the correction. I admit I've not fiddled with Haskell's equivalents to Active Patterns to any great extent - as since I mention in the original comment I didn't hugely see the motivation in that context. I really only mentioned them since I assumed more people would be familiar with haskell.
- jdh30 16y agoHaskell doesn't have active patterns. Although they were originally proposed for Haskell by Wadler, they don't make so much sense with non-strict evaluation because you can just write code to compute the result and match over it safe in the knowledge that it will be computed on-demand only as far as required.