Is there a way to refactor this:
let collide (b1 : Box) (b2 : Box) =
if bottom b1 > top b2
then false
else if top b1 < bottom b2
then false
else if right b1 < left b2
then false
else if left b1 > right b2
then false
else true
in a more readable way than this:
let collide (b1 : Box) (b2 : Box) =
match () with
| _ when bottom b1 > top b2 -> false
| _ when top b1 < bottom b2 -> false
| _ when right b1 < left b2 -> false
| _ when left b1 > right b2 -> false
| _ -> true
?
I am thinking of something similar to multi-way if-expressions in from GHC 7.6.1: http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/syntax-extns.html#multi-way-if .
1 Answer