-
Notifications
You must be signed in to change notification settings - Fork 0
/
Types.hs
45 lines (39 loc) · 1.3 KB
/
Types.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
43
44
45
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE FlexibleInstances #-}
module Types
( Vote(..)
, ListVote(..)
, RankVote(..)
, GCandidate(..)
, SBCandidate(..)
) where
import qualified Data.Map as Map
import Data.Time.Clock (UTCTime)
import Data.Time.Format () -- Show UTCTime
data Vote = Vote
{ time :: UTCTime
, username :: String
, governor :: Maybe GCandidate
, prop1 :: Maybe Bool
, prop2 :: Maybe Bool
, prop45 :: Maybe Bool
, prop46 :: Maybe Bool
, prop47 :: Maybe Bool
, prop48 :: Maybe Bool
, listvote :: Maybe (ListVote SBCandidate)
, rankvote :: Maybe (RankVote SBCandidate)
} deriving (Eq, Show)
newtype ListVote a = ListVote { unLV :: [a] }
deriving (Eq, Show)
newtype RankVote a = RankVote { unRV :: Map.Map a (Maybe Int) }
deriving (Eq, Show)
data GCandidate = Brown | Kashkari
deriving (Eq, Ord, Enum, Bounded, Show)
data SBCandidate = Black | Chin | Gray | Blanchard
deriving (Eq, Ord, Enum, Bounded)
instance Show SBCandidate where
show Black = "Paul Black"
show Chin = "Elliot Chin"
show Gray = "Ross Stapleton-Gray"
show Blanchard = "Charles Blanchard"