Last active
February 9, 2017 20:56
-
-
Save dszakallas/7e5902396b85f797ab055a9c6c04f01a to your computer and use it in GitHub Desktop.
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 = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday | |
deriving (Eq, Ord, Show, Read, Bounded, Enum) | |
-- and that's it. we have everything we need | |
-- david@mac:~% stack ghci | |
-- λ> Monday == Tuesday | |
-- False | |
-- λ> Monday == Monday | |
-- True | |
-- λ> Tuesday > Monday | |
-- True | |
-- λ> minBound :: Day | |
-- Monday | |
-- λ> maxBound :: Day | |
-- Sunday | |
-- λ> import qualified Data.Set as Set | |
-- λ> let orderedSet = Set.toList . foldl (flip Set.insert) Set.empty | |
-- λ> orderedSet [Wednesday, Wednesday, Monday, Tuesday, Friday] | |
-- [Monday,Tuesday,Wednesday,Friday] | |
-- λ> read "Monday" :: Day | |
-- Monday | |
-- λ> show Tuesday | |
-- "Tuesday" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment