/
20110823.hs
44 lines (26 loc) · 888 Bytes
/
20110823.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import Test.QuickCheck
import Data.List
data Weekday = Mon | Tue | Wed | Thu | Fri | Sat | Sun
deriving (Eq, Ord, Show, Enum)
-- problem 1 a:
instance Arbitrary Weekday where
arbitrary = elements [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
prop_listSorted :: [Weekday] -> Bool
prop_listSorted inp = (sort inp) == (mysort inp)
prop_lengthKept :: [Weekday] -> Bool
prop_lengthKept inp = length (mysort inp) == length inp
-- type checking shit
mysort :: [Weekday] -> [Weekday]
mysort = undefined
-- problem 2 a:
-- a type DateSet
-- a function isIn :: Date -> DateSet -> Bool
-- a function upperBound :: DateSet -> Date
-- toList :: DateSet -> [Date]
-- start from
-- epochD = ReadD "1970-01-01"
-- assume functions
-- readD :: String -> Date
-- showD :: Date -> String
-- accessor function weekday, monthday, yearday :: Date -> Int
-- assume nextD :: Date -> Date