aboutsummaryrefslogtreecommitdiff
path: root/hsm-command/Hsm/Command/Readline.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hsm-command/Hsm/Command/Readline.hs')
-rw-r--r--hsm-command/Hsm/Command/Readline.hs40
1 files changed, 0 insertions, 40 deletions
diff --git a/hsm-command/Hsm/Command/Readline.hs b/hsm-command/Hsm/Command/Readline.hs
deleted file mode 100644
index 1caa562..0000000
--- a/hsm-command/Hsm/Command/Readline.hs
+++ /dev/null
@@ -1,40 +0,0 @@
-{-# LANGUAGE DataKinds #-}
-{-# LANGUAGE TypeFamilies #-}
-
-module Hsm.Command.Readline
- ( Readline
- , readline
- , runReadline
- ) where
-
-import Effectful (Dispatch(Static), DispatchOf, Eff, IOE, (:>))
-import Effectful.Dispatch.Static qualified as S
-import Effectful.Log (Log)
-import Effectful.Resource (Resource, allocate)
-import Hsm.Core.Log (flushLogger)
-import System.Console.Haskeline qualified as H
-import System.Console.Haskeline.IO qualified as H
-
-data Readline a b
-
-type instance DispatchOf Readline = Static S.WithSideEffects
-
-newtype instance S.StaticRep Readline =
- Readline H.InputState
-
-readline :: (Log :> es, Readline :> es) => Eff es (Maybe String)
-readline = do
- flushLogger
- Readline hdl <- S.getStaticRep
- 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 (H.initializeInput settings) H.cancelInput
- S.evalStaticRep (Readline handle) action
- where
- settings = H.defaultSettings {H.historyFile = Just ".hsm_command_history"}