-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathAppDefs.hs
More file actions
56 lines (44 loc) · 1.49 KB
/
AppDefs.hs
File metadata and controls
56 lines (44 loc) · 1.49 KB
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
{-# LANGUAGE TemplateHaskell #-}
module AppDefs where
import Control.Lens
import Control.Monad.Reader
import Control.Concurrent.STM
import Data.Word
import qualified Codec.Picture as JP
import PersistConfig (PersistConfig)
import HueJSON
-- Some definitions for the App module which we split out here
-- Channel with light ID and update pair
type LightUpdateTChan = TChan (LightID, LightUpdate)
-- Different updates to the displayed light state
data LightUpdate = LU_OnOff !Bool
| LU_Brightness !Word8
| LU_Color !String -- HTML color string
| LU_GroupLastOff !GroupName
| LU_GroupFirstOn !GroupName
| LU_LastOff
| LU_FirstOn
deriving Show
-- Application state
data AppEnv = AppEnv
{ _aePC :: !(TVar PersistConfig)
, _aeBC :: !BridgeConfig
, _aeLights :: !(TVar Lights)
, _aeLightGroups :: !(TVar LightGroups)
, _aeBridgeScenes :: !BridgeScenes
, _aeBroadcast :: !LightUpdateTChan
, _aeColorPickerImg :: !(JP.Image JP.PixelRGB8)
, _aeCmdLineOpts :: !CmdLineOpts
, _aeConnectedUsers :: !(TVar Int)
}
data CmdLineOpts = CmdLineOpts
{ _cloPort :: !Int
, _cloOnlyLocalhost :: !Bool
, _cloPollInterval :: !Int
, _cloTraceHTTP :: !Bool
}
makeLenses ''AppEnv
makeLenses ''CmdLineOpts
-- Our main application monad
type AppT m = ReaderT AppEnv m
type AppIO = AppT IO