Created
August 18, 2013 01:52
-
-
Save weskerfoot/6259553 to your computer and use it in GitHub Desktop.
days of the week
This file contains hidden or 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
data Day = Mon | Tues | Wed | Thurs | Fri | Sat | Sun deriving (Enum, Ord, Eq, Show) | |
daysFromNow :: Day -> Int -> Day | |
daysFromNow day n = toEnum $ (fromEnum day) + n `mod` 6 | |
main = do | |
print $ daysFromNow Mon 2 | |
print $ daysFromNow Sat 7 | |
print $ daysFromNow Wed 13 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment