Using case for a multi-way if

coding-style, haskell

Solution

There is nothing wrong with `case ()`; it is the best you have for this use-case unless you want to use very recent syntactic and non-standard-extensions like GHC’s multi-way-if.

Problem

Today, I found myself typing the following code: ``` case () of _ | x < 15 -> ... _ | x < 25 -> ... _ | x < 50 -> ... _ -> ... ``` The meaning of this is straight-forward enough, but it just feels... wrong to utter `case ()`. Does anybody have a better suggestion? I suppose since I'm branding on `x`, I could have written `case x`. But that still leaves me with nothing to actually pattern-match on; it's all about the guards. And that still feels weird.

Original source