{-# 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 Logs = '["drive", "gpio", "pwm", "repl"] $(makeLoggerOptionParser @Logs "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 @Logs opts & runEff