[Haskell-cafe] MultiCase alternative

MarLinn monkleyon at gmail.com
Sun Jun 18 13:32:44 UTC 2017


> Sometimes pain is Nature's way of telling you you're doing it wrong.
>

This. This not only goes for or-patterns, but also for the pain that 
leads you to use View Patterns. They are an interesting concept, and the 
indirection makes it more "fun" to think about. We like flexing our 
minds that little bit sometimes. But they are also easily abused to hide 
shortcomings of the underlying model instead of fixing them. And in the 
real world, that's often what they end up being used for. Almost all 
code I have seen that actually used View Patterns got more readable by 
refactoring.

Don't get me wrong: I'm not saying they should never be used. But I've 
fallen into the trap of overusing this pattern myself, and almost always 
I regretted it and/or refactored. Of all the code I've seen there has 
maybe been a handful of instances where View Patterns actually 
contributed in a positive way.

Call me a hypocrite after I brought up the ridiculous concept of 
"pattern-level functions" earlier in this thread, but that's the 
difference between theory and practice I suppose.

Cheers,
MarLinn



More information about the Haskell-Cafe mailing list