diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-16 19:22:18 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-17 19:16:43 -0800 |
commit | e3ea039428545e185b38c5633fe3576ab32f1f8e (patch) | |
tree | 56ab8d1248b4387ceab6094305e7a75699c4e393 /hsm-gpio/Hsm/GPIO.hs | |
parent | e1fa79eb713c249055fb23fcc6684a94f77d8368 (diff) |
Cleans excessive type annotations
Diffstat (limited to 'hsm-gpio/Hsm/GPIO.hs')
-rw-r--r-- | hsm-gpio/Hsm/GPIO.hs | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/hsm-gpio/Hsm/GPIO.hs b/hsm-gpio/Hsm/GPIO.hs index e3deabd..bc08ef5 100644 --- a/hsm-gpio/Hsm/GPIO.hs +++ b/hsm-gpio/Hsm/GPIO.hs @@ -64,20 +64,12 @@ gpioset state gpios periods = do localDomain domain $ logTrace_ $ "Calling command: " <> pack command E.unsafeEff_ $ callCommand command where - command :: String + lineArg gpio = show gpio <> "=" <> stateStr state <> " " command = "gpioset -t" <> intercalate "," (show <$> periods) <> " " <> concatMap lineArg (toList gpios) - -- - lineArg :: GPIO -> String - lineArg gpio = show gpio <> "=" <> stateStr state <> " " - -getGPIOs :: GPIOEffect key :> es => key -> Eff es (Set GPIO) -getGPIOs key = do - GPIOEffect mapper <- E.getStaticRep - return $ mapper key logReport :: (Log :> es, Show key) => Bool -> key -> [Int] -> Set GPIO -> Eff es () @@ -85,7 +77,6 @@ logReport state key periods gpios = do localDomain domain $ logTrace_ report flushLogger where - report :: Text report = "Setting pins " <> pack (show gpios) @@ -103,29 +94,27 @@ toggle :: -> [Int] -> Eff es () toggle state key periods = do - gpios <- getGPIOs key - logReport state key periods gpios - gpioset state gpios periods + GPIOEffect mapper <- E.getStaticRep + set $ mapper key + where + set gpios = do + logReport state key periods gpios + gpioset state gpios periods runGPIO :: - forall key es a. (IOE :> es, Log :> es, Bounded key, Enum key) + (IOE :> es, Log :> es, Bounded key, Enum key) => (key -> Set GPIO) -> Eff (GPIOEffect key : es) a -> Eff es a runGPIO mapper action = - E.evalStaticRep (GPIOEffect mapper) $ finally action releaser + E.evalStaticRep (GPIOEffect mapper) $ finally action release where - gpios :: Set GPIO gpios = unions $ mapper <$> [minBound .. maxBound] - -- - endReport :: Text endReport = "Setting all mapped pins " <> pack (show gpios) <> " to state " <> stateStr False - -- - releaser :: Eff (GPIOEffect key : es) () - releaser = do + release = do localDomain domain $ logTrace_ endReport gpioset False gpios [0] |