diff options
Diffstat (limited to 'hsm-drive/Test/Drive.hs')
-rw-r--r-- | hsm-drive/Test/Drive.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/hsm-drive/Test/Drive.hs b/hsm-drive/Test/Drive.hs new file mode 100644 index 0000000..e6332fd --- /dev/null +++ b/hsm-drive/Test/Drive.hs @@ -0,0 +1,39 @@ +{-# LANGUAGE TemplateHaskell #-} + +import Control.Monad.Loops (whileJust_) +import Data.Function ((&)) +import Effectful (runEff) +import Effectful.Dispatch.Static (unEff, unsafeEff) +import GHC.TypeLits (AppendSymbol) +import Hsm.Core.App (bootstrapApp) +import Hsm.Drive (drive, runDrive) +import Hsm.GPIO (runGPIO) +import Hsm.Log (Severity (Info), runLogsOpt) +import Hsm.Log.Options (makeLoggerOptionParser) +import Hsm.PWM (runPWM) +import Hsm.Repl (repl, runRepl) +-- Import full module for cleaner `-ddump-splices` output +-- Avoids package/module qualifiers in generated code +import Options.Applicative +import System.IO.Echo (withoutInputEcho) + +type Name = "test-drive" + +type Prompt = AppendSymbol Name " λ " + +type Imports = '["Hsm.Drive", "Prelude"] + +type Loggers = '["drive", "gpio", "pwm", "repl"] + +$(makeLoggerOptionParser @Loggers "Options" "parser" 'Info) + +main :: IO () +main = + bootstrapApp parser "Launch Drive Service Test Application" $ \opts -> + whileJust_ repl (\actions -> unsafeEff $ withoutInputEcho . unEff (drive actions)) + & runDrive + & runGPIO @Name + & runPWM + & runRepl @Prompt @Imports + & runLogsOpt @Options @Loggers opts + & runEff |