aboutsummaryrefslogtreecommitdiff
path: root/hsm-pwm
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-pwm')
-rw-r--r--hsm-pwm/Hsm/PWM.hs12
-rw-r--r--hsm-pwm/hsm-pwm.cabal1
2 files changed, 4 insertions, 9 deletions
diff --git a/hsm-pwm/Hsm/PWM.hs b/hsm-pwm/Hsm/PWM.hs
index 400e704..9a4fe5c 100644
--- a/hsm-pwm/Hsm/PWM.hs
+++ b/hsm-pwm/Hsm/PWM.hs
@@ -20,7 +20,7 @@ module Hsm.PWM
where
import Control.Concurrent (threadDelay)
-import Control.Monad (forM_, void)
+import Control.Monad (forM_)
import Control.Monad.Loops (untilM_)
import Effectful (Dispatch (Static), DispatchOf, Eff, IOE, liftIO, (:>))
import Effectful.Dispatch.Static
@@ -29,7 +29,7 @@ import Effectful.Dispatch.Static
, evalStaticRep
, unsafeEff_
)
-import Effectful.Resource (Resource, allocateEff_)
+import Effectful.Exception (bracket_)
import Hsm.Core.Serial (makeSerial)
import Hsm.Log (Log, Severity (Info, Trace), logMsg)
import System.FilePath ((</>))
@@ -100,12 +100,8 @@ setCycleDuration channel cycleDuration = do
setDutyCycle channel $ cycleDuration `div` 2
setEnable channel True
-runPWM
- :: (IOE :> es, Log "pwm" :> es, Resource :> es) => Eff (PWM : es) a -> Eff es a
-runPWM action =
- evalStaticRep (PWM ()) $ do
- void $ allocateEff_ pwmAlloc pwmDealloc
- action
+runPWM :: (IOE :> es, Log "pwm" :> es) => Eff (PWM : es) a -> Eff es a
+runPWM = evalStaticRep (PWM ()) . bracket_ pwmAlloc pwmDealloc
where
exportPath = chipPath </> "export"
unexportPath = chipPath </> "unexport"
diff --git a/hsm-pwm/hsm-pwm.cabal b/hsm-pwm/hsm-pwm.cabal
index 2f3134a..808c7cb 100644
--- a/hsm-pwm/hsm-pwm.cabal
+++ b/hsm-pwm/hsm-pwm.cabal
@@ -12,7 +12,6 @@ library
, hsm-core
, hsm-log
, monad-loops
- , resourcet-effectful
, unix
default-language: GHC2024