What you are asking is a question of style, so there is no right or wrong answer. However, here are a couple of suggestions.
Firstly you are writing the equivalent of this pattern:
isTrue value | value == True = True
| otherwise = False
Which can of course be simplified to:
isTrue value = value
Secondly, as you are checking multiple tests that all need to be true, you can make use of the and
function and pass your tests as elements of a list. This will return True
if all elements are True
, otherwise it will short-circuit and return False
.
Putting these two ideas together we get:
checkMatch :: Person -> Person -> Bool
checkMatch seeker candidate
= and [gender candidate == preferedGender seeker,
gender seeker == preferedGender candidate,
minAcceptableAge seeker <= age candidate,
maxAcceptableAge seeker >= age candidate,
minAcceptableAge candidate <= age seeker,
maxAcceptableAge candidate >= age seeker]
...which is probably how I would write it.