forked from charleso/haskell-in-haste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVote.hs
72 lines (63 loc) · 1.64 KB
/
Vote.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Chat.Bot.Vote where
import Chat.Bot.Answer.Vote
import Chat.Bot.Misc.Vote
import Chat.Data
{-
LEVEL: Medium
USAGE: /poll question answer answer answer
USAGE: /poll
USAGE: /vote answer
Create a poll for people to vote on.
EXAMPLE:
> /poll Tabs or Spaces? Tabs Spaces
Poll created
> /vote Tabs
> /vote Spaces
> /vote Tabs
> /poll
Tabs or Spaces? Tabs: 2 Spaces: 1
-}
-- See Misc/Vote.hs
{-
data Vote = Vote String Int
data Poll = Poll String [Vote]
-}
-- |
--
-- >>> createPoll "Tabs" ["Yes","No"]
-- Poll "Tabs" [Vote "Yes" 0,Vote "No" 0]
--
-- HINTS:
--
-- map :: (String -> Vote) -> [String] -> [Vote]
--
createPoll :: String -> [String] -> Poll
createPoll question options =
notImplemented "Vote.createPoll" (createPollAnswer question options)
-- |
--
-- >>> castVote (Poll "Tabs" [Vote "Yes" 0,Vote "No" 0]) "Yes"
-- Poll "Tabs" [Vote "Yes" 1,Vote "No" 0]
-- >>> castVote (Poll "Tabs" [Vote "Yes" 1,Vote "No" 0]) "Yes"
-- Poll "Tabs" [Vote "Yes" 2,Vote "No" 0]
-- >>> castVote (Poll "Tabs" [Vote "Yes" 2,Vote "No" 0]) "Maybe"
-- Poll "Tabs" [Vote "Yes" 2,Vote "No" 0]
--
-- HINTS:
--
-- map :: (Vote -> Vote) -> [Vote] -> [Vote]
--
castVote :: Poll -> String -> Poll
castVote (Poll question options) vote =
notImplemented "Vote.castVote" (castVoteAnswer (Poll question options) vote)
-- |
--
-- HINTS:
--
-- map :: (Vote -> String) -> [Vote] -> [String]
-- unlines :: [String] -> String
-- ++ :: String -> String -> String
--
pollRender :: Poll -> String
pollRender (Poll question options) =
notImplemented "Vote.pollRender" (pollRenderAnswer (Poll question options))