aboutsummaryrefslogtreecommitdiff
path: root/hsm-core/Hsm
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-09-07 19:23:37 +0000
committerPaul Oliver <contact@pauloliver.dev>2025-09-07 19:49:03 +0000
commit89aab732dc3d484b99c0761728285bca6f6b1ba0 (patch)
treee2b4ca6656758dc9f398b9b1de2e6d92670b77df /hsm-core/Hsm
parentef0713cbd90d6b84da7ea67e6dfc1fe5ab5bff86 (diff)
Adds another formatting/cleaning roundHEADmaster
Diffstat (limited to 'hsm-core/Hsm')
-rw-r--r--hsm-core/Hsm/Core/App.hs23
-rw-r--r--hsm-core/Hsm/Core/Bracket.hs5
-rw-r--r--hsm-core/Hsm/Core/Serial.hs21
3 files changed, 31 insertions, 18 deletions
diff --git a/hsm-core/Hsm/Core/App.hs b/hsm-core/Hsm/Core/App.hs
index 12849d4..88dabb2 100644
--- a/hsm-core/Hsm/Core/App.hs
+++ b/hsm-core/Hsm/Core/App.hs
@@ -1,9 +1,20 @@
+-- Provides combinators for bootstrapping applications with:
+-- - Automated command-line parsing
+-- - Help text generation
module Hsm.Core.App
- ( runApp
- ) where
+ ( bootstrapApp
+ , bootstrapAppNoEcho
+ )
+where
-import Effectful (Eff, IOE, runEff)
-import Options.Applicative (Parser, (<**>), execParser, fullDesc, helper, info, progDesc)
+import Data.Composition ((.:.))
+import Options.Applicative (Parser, execParser, fullDesc, helper, info, progDesc, (<**>))
+import System.IO.Echo (withoutInputEcho)
-runApp :: Parser o -> String -> (o -> Eff '[ IOE] a) -> IO a
-runApp parser desc app = execParser (info (parser <**> helper) $ fullDesc <> progDesc desc) >>= runEff . app
+-- Launches a console application with input echo enabled
+bootstrapApp :: Parser o -> String -> (o -> IO a) -> IO a
+bootstrapApp parser desc app = execParser (info (parser <**> helper) $ fullDesc <> progDesc desc) >>= app
+
+-- Launches an application with hidden input echo
+bootstrapAppNoEcho :: Parser o -> String -> (o -> IO a) -> IO a
+bootstrapAppNoEcho = withoutInputEcho .:. bootstrapApp
diff --git a/hsm-core/Hsm/Core/Bracket.hs b/hsm-core/Hsm/Core/Bracket.hs
index f666d86..92428de 100644
--- a/hsm-core/Hsm/Core/Bracket.hs
+++ b/hsm-core/Hsm/Core/Bracket.hs
@@ -4,10 +4,11 @@ module Hsm.Core.Bracket
( bracketConst
, bracketCont
, bracketLiftIO_
- ) where
+ )
+where
import Control.Monad.Trans.Cont (Cont, cont)
-import Effectful (Eff, IOE, (:>), liftIO)
+import Effectful (Eff, IOE, liftIO, (:>))
import Effectful.Exception (bracket, bracket_)
-- Ignores allocated resource in the action
diff --git a/hsm-core/Hsm/Core/Serial.hs b/hsm-core/Hsm/Core/Serial.hs
index 9a4d2b7..7c607ff 100644
--- a/hsm-core/Hsm/Core/Serial.hs
+++ b/hsm-core/Hsm/Core/Serial.hs
@@ -2,21 +2,22 @@
module Hsm.Core.Serial
( makeSerial
- ) where
+ )
+where
import GHC.Num (integerFromInt)
import Language.Haskell.TH
- ( Body(NormalB)
- , Clause(Clause)
- , Con(NormalC)
- , Dec(DataD, FunD, SigD)
- , DerivClause(DerivClause)
- , Exp(LitE)
- , Lit(IntegerL)
+ ( Body (NormalB)
+ , Clause (Clause)
+ , Con (NormalC)
+ , Dec (DataD, FunD, SigD)
+ , DerivClause (DerivClause)
+ , Exp (LitE)
+ , Lit (IntegerL)
, Name
- , Pat(ConP)
+ , Pat (ConP)
, Q
- , Type(AppT, ArrowT, ConT)
+ , Type (AppT, ArrowT, ConT)
, mkName
)