diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-09-12 01:43:15 +0000 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-09-12 01:43:15 +0000 |
commit | e36a24df176cdbbd634738115f847e4fa46a0aea (patch) | |
tree | 0e76c7651a0b3ec4d190bdf4afd4614630717733 /hsm-drive | |
parent | ac5a85abac1a47645713d3b7539fccb1b744dd85 (diff) |
Adds `Logs` constraint combinator
Diffstat (limited to 'hsm-drive')
-rw-r--r-- | hsm-drive/Hsm/Drive.hs | 7 | ||||
-rw-r--r-- | hsm-drive/Test/Drive.hs | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/hsm-drive/Hsm/Drive.hs b/hsm-drive/Hsm/Drive.hs index f9bdc43..cf8e4f1 100644 --- a/hsm-drive/Hsm/Drive.hs +++ b/hsm-drive/Hsm/Drive.hs @@ -18,7 +18,7 @@ import Effectful (Dispatch (Static), DispatchOf, Eff, IOE, (:>)) import Effectful.Dispatch.Static (SideEffects (WithSideEffects), StaticRep, evalStaticRep, unsafeEff_) import Effectful.Exception (AsyncException, bracket_, handle) import Hsm.GPIO (GPIO, GPIOPin (..), active, inactive, setPins) -import Hsm.Log (Log, Severity (Attention, Info, Trace), logMsg) +import Hsm.Log (Logs, Severity (Attention, Info, Trace), logMsg) import Hsm.PWM (PWM, PWMChannel (..), setCycleDuration) data Drive (a :: * -> *) (b :: *) @@ -115,8 +115,7 @@ step = PWM3 -- Executes a sequence of drive actions with interruption support -- Wakes motors from SLEEP mode during execution and guarantees return to SLEEP -- mode upon completion or interruption. -drive - :: (GPIO :> es, IOE :> es, Log "drive" :> es, Log "gpio" :> es, Log "pwm" :> es, PWM :> es) => [Action] -> Eff es () +drive :: (GPIO :> es, IOE :> es, Logs '["drive", "gpio", "pwm"] es, PWM :> es) => [Action] -> Eff es () drive actions = bracket_ awaken sleep . handle handler . forM_ actions $ \action -> do logMsg @"drive" Trace $ "Running action: " <> show action @@ -186,7 +185,7 @@ drive actions = -- in its current position. runAction (Stop duration) = delay duration -runDrive :: (GPIO :> es, IOE :> es, Log "drive" :> es, Log "gpio" :> es) => Eff (Drive : es) a -> Eff es a +runDrive :: (GPIO :> es, IOE :> es, Logs '["drive", "gpio"] es) => Eff (Drive : es) a -> Eff es a runDrive = evalStaticRep (Drive ()) . bracket_ enterActive exitActive where alwaysActive = [ms1, ms2, ms3, notReset] diff --git a/hsm-drive/Test/Drive.hs b/hsm-drive/Test/Drive.hs index e6332fd..96bd4f4 100644 --- a/hsm-drive/Test/Drive.hs +++ b/hsm-drive/Test/Drive.hs @@ -23,9 +23,9 @@ type Prompt = AppendSymbol Name " λ " type Imports = '["Hsm.Drive", "Prelude"] -type Loggers = '["drive", "gpio", "pwm", "repl"] +type Logs = '["drive", "gpio", "pwm", "repl"] -$(makeLoggerOptionParser @Loggers "Options" "parser" 'Info) +$(makeLoggerOptionParser @Logs "Options" "parser" 'Info) main :: IO () main = @@ -35,5 +35,5 @@ main = & runGPIO @Name & runPWM & runRepl @Prompt @Imports - & runLogsOpt @Options @Loggers opts + & runLogsOpt @Options @Logs opts & runEff |