aboutsummaryrefslogtreecommitdiff
path: root/hsm-drive/Test/Drive.hs
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-09-11 03:04:36 +0000
committerPaul Oliver <contact@pauloliver.dev>2025-09-12 01:08:04 +0000
commitac5a85abac1a47645713d3b7539fccb1b744dd85 (patch)
treef0107a391a5f937b3d076f0edd1c8df9c3bbc0c2 /hsm-drive/Test/Drive.hs
parent89aab732dc3d484b99c0761728285bca6f6b1ba0 (diff)
Adds `hsm-drive`
Diffstat (limited to 'hsm-drive/Test/Drive.hs')
-rw-r--r--hsm-drive/Test/Drive.hs39
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