diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-16 19:22:18 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-24 16:36:25 -0800 |
commit | f912485e9612623888e3e032fb975771c22d2b16 (patch) | |
tree | 01a198647531152d974d4468ae9e558b7689bf2f /hsm-command/Hsm/Command | |
parent | c18d30706ce647a7b640d73514eecb0aa442873c (diff) |
Cleans excessive type annotations
Diffstat (limited to 'hsm-command/Hsm/Command')
-rw-r--r-- | hsm-command/Hsm/Command/Command.hs | 5 | ||||
-rw-r--r-- | hsm-command/Hsm/Command/Readline.hs | 23 |
2 files changed, 8 insertions, 20 deletions
diff --git a/hsm-command/Hsm/Command/Command.hs b/hsm-command/Hsm/Command/Command.hs index 3b53287..53964c4 100644 --- a/hsm-command/Hsm/Command/Command.hs +++ b/hsm-command/Hsm/Command/Command.hs @@ -39,13 +39,10 @@ data Command | Rotate Angle Speed Int deriving (Binary, Generic, Read, Show) -commandStream :: - forall es. (Log :> es, Readline :> es) - => S.Stream (Eff es) Command +commandStream :: (Log :> es, Readline :> es) => S.Stream (Eff es) Command commandStream = S.mapMaybeM (parse . fromJust) $ S.takeWhile isJust $ S.repeatM readline where - parse :: String -> Eff es (Maybe Command) parse string = case readEither string of Left err -> logAttention_ (pack err) >> return Nothing diff --git a/hsm-command/Hsm/Command/Readline.hs b/hsm-command/Hsm/Command/Readline.hs index 428ed50..1caa562 100644 --- a/hsm-command/Hsm/Command/Readline.hs +++ b/hsm-command/Hsm/Command/Readline.hs @@ -22,28 +22,19 @@ type instance DispatchOf Readline = Static S.WithSideEffects newtype instance S.StaticRep Readline = Readline H.InputState -readline :: - forall es. (Log :> es, Readline :> es) - => Eff es (Maybe String) +readline :: (Log :> es, Readline :> es) => Eff es (Maybe String) readline = do flushLogger Readline hdl <- S.getStaticRep - S.unsafeEff_ $ nextLine hdl - where - nextLine :: H.InputState -> IO (Maybe String) - nextLine hdl = - H.queryInput hdl - $ H.handleInterrupt (return Nothing) - $ H.withInterrupt - $ H.getInputLine "% " + S.unsafeEff_ + $ H.queryInput hdl + $ H.handleInterrupt (return Nothing) + $ H.withInterrupt + $ H.getInputLine "% " runReadline :: (IOE :> es, Resource :> es) => Eff (Readline : es) a -> Eff es a runReadline action = do - handle <- snd <$> allocate istate H.cancelInput + handle <- snd <$> allocate (H.initializeInput settings) H.cancelInput S.evalStaticRep (Readline handle) action where - settings :: H.Settings IO settings = H.defaultSettings {H.historyFile = Just ".hsm_command_history"} - -- - istate :: IO H.InputState - istate = H.initializeInput settings |