blob: caf24a6306a480945d6ac8dfc91e9c674c157121 (
plain)
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
|
{-# LANGUAGE TemplateHaskell #-}
import Control.Concurrent (threadDelay)
import Control.Monad (forever)
import Data.Function ((&))
import Effectful (liftIO, runEff)
import Hsm.Battery (readBatteryState, runBattery)
import Hsm.Core.App (bootstrapApp)
import Hsm.Log (Severity (Info), logMsg, runLogsOpt)
import Hsm.Log.Options (makeLoggerOptionParser)
-- Import full module for cleaner `-ddump-splices` output
-- Avoids package/module qualifiers in generated code
import Options.Applicative
type Logs = '["battery"]
$(makeLoggerOptionParser @Logs "Options" "parser" 'Info)
main :: IO ()
main =
bootstrapApp parser "Launch Battery Monitoring Test Application" $ \opts ->
(forever $ liftIO (threadDelay 1000000) >> readBatteryState >>= logMsg Info . show)
& runBattery
& runLogsOpt @Options @Logs opts
& runEff
|