diff options
Diffstat (limited to 'hsm-dummy-blinker/Main.hs')
-rw-r--r-- | hsm-dummy-blinker/Main.hs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/hsm-dummy-blinker/Main.hs b/hsm-dummy-blinker/Main.hs index cfc6654..88b7b5f 100644 --- a/hsm-dummy-blinker/Main.hs +++ b/hsm-dummy-blinker/Main.hs @@ -27,30 +27,25 @@ data Env = Env $(deriveFromYaml ''Env) stateOn :: F.FsmState () Bool Env Bool -stateOn = F.FsmState "on" action - where - action :: () -> Env -> Bool -> F.FsmOutput () Bool Env Bool - action _ _ sta = - F.FsmOutput - (Just $ F.FsmResult sta False stateOff) - [(LogInfo, "Turning on blinker")] +stateOn = + F.FsmState "on" $ \_ _ sta -> + F.FsmOutput + (Just $ F.FsmResult sta False stateOff) + [(LogInfo, "Turning on blinker")] stateOff :: F.FsmState () Bool Env Bool -stateOff = F.FsmState "off" action - where - action :: () -> Env -> Bool -> F.FsmOutput () Bool Env Bool - action _ _ sta = - F.FsmOutput - (Just $ F.FsmResult sta True stateOn) - [(LogInfo, "Turning off blinker")] +stateOff = + F.FsmState "off" $ \_ _ sta -> + F.FsmOutput + (Just $ F.FsmResult sta True stateOn) + [(LogInfo, "Turning off blinker")] handle :: - forall es. (GPIOEffect () :> es, Log :> es, Reader Env :> es) + (GPIOEffect () :> es, Log :> es, Reader Env :> es) => S.Stream (Eff es) Bool -> Eff es () handle = S.fold S.drain . S.mapM handler where - handler :: Bool -> Eff es () handler sta = do env <- ask @Env toggle sta () [env.period, 0] |