Last active
December 22, 2015 20:19
-
-
Save mstksg/6525682 to your computer and use it in GitHub Desktop.
Assertion DSL for complex conditional
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Maybe (isJust) | |
assert :: Bool -> Maybe () | |
assert True = Just () | |
assert False = Nothing | |
checkAssertions :: Maybe () -> Bool | |
checkAssertions = isJust | |
checkMatch :: Person -> Person -> Bool | |
checkMatch seeker candidate = checkAssertions $ do | |
assert $ gender candidate == preferedGender seeker | |
assert $ gender seeker == preferedGender candidate | |
assert $ minAcceptableAge seeker <= age candidate | |
assert $ maxAcceptableAge seeker >= age candidate | |
assert $ minAcceptableAge candidate <= age seeker | |
assert $ maxAcceptableAge cadidate >= age seeker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment