diff options
author | joe <joe@jerkface.net> | 2018-05-24 19:35:52 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-24 19:35:52 -0400 |
commit | 3de9992f3e30a911617737827bce3242db0cc978 (patch) | |
tree | 9f2cd558ef943876875e99a14f76a49511f51427 /Announcer.hs | |
parent | 07584194c4c7fa270b78095970cf0d4101005b12 (diff) |
Dropped dependency on generic-data for now.
Diffstat (limited to 'Announcer.hs')
-rw-r--r-- | Announcer.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Announcer.hs b/Announcer.hs index 2b96c421..72d70a1e 100644 --- a/Announcer.hs +++ b/Announcer.hs | |||
@@ -35,7 +35,7 @@ import Data.Maybe | |||
35 | import Data.Ord | 35 | import Data.Ord |
36 | import Data.Time.Clock.POSIX | 36 | import Data.Time.Clock.POSIX |
37 | import qualified GHC.Generics as Generics | 37 | import qualified GHC.Generics as Generics |
38 | import Generic.Data.Internal.Meta as Lyxia | 38 | -- import Generic.Data.Internal.Meta as Lyxia |
39 | 39 | ||
40 | newtype AnnounceKey = AnnounceKey ByteString | 40 | newtype AnnounceKey = AnnounceKey ByteString |
41 | deriving (Hashable,Ord,Eq) | 41 | deriving (Hashable,Ord,Eq) |
@@ -54,13 +54,21 @@ data ScheduledItem | |||
54 | | SearchResult (STM (IO ())) | 54 | | SearchResult (STM (IO ())) |
55 | | StopAnnouncer | 55 | | StopAnnouncer |
56 | -- Can't use Data because STM and IO. :( | 56 | -- Can't use Data because STM and IO. :( |
57 | -- deriving Data {- itemStatusNum sch = constrIndex $ toConstr sch -} | 57 | -- deriving Data {- itemStatusNum sch = constrIndex $ toConstr sch -} |
58 | -- Using Generic to accomplish the job. | 58 | -- Using Generic works with Lyxia's generic-data package... |
59 | -- {- itemStatusNum sch = Lyxia.conIdToInt $ Lyxia.conId sch -} | ||
60 | -- For now, make sure to keep 'itemStatusNum' up to date with 'ScheduledItem'. | ||
59 | deriving Generics.Generic | 61 | deriving Generics.Generic |
60 | 62 | ||
61 | 63 | ||
62 | itemStatusNum :: ScheduledItem -> Int | 64 | itemStatusNum :: ScheduledItem -> Int |
63 | itemStatusNum sch = Lyxia.conIdToInt $ Lyxia.conId sch | 65 | itemStatusNum (DeleteAnnouncement ) = 0 |
66 | itemStatusNum (NewAnnouncement {}) = 1 | ||
67 | itemStatusNum (SearchFinished {}) = 2 | ||
68 | itemStatusNum (Announce {}) = 3 | ||
69 | itemStatusNum (SearchResult {}) = 4 | ||
70 | itemStatusNum (StopAnnouncer ) = 5 | ||
71 | itemStatusNum _ = error "itemStatusNum not in sync with ScheduledItem declaration." | ||
64 | 72 | ||
65 | data Announcer = Announcer | 73 | data Announcer = Announcer |
66 | { scheduled :: TVar (PSQ' AnnounceKey POSIXTime ScheduledItem) | 74 | { scheduled :: TVar (PSQ' AnnounceKey POSIXTime ScheduledItem) |