diff options
author | Paul Oliver <contact@pauloliver.dev> | 2024-08-24 11:57:18 -0700 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2024-12-01 07:01:30 -0800 |
commit | f0854265f7a1b59078308965d33fe2583a5c0f9c (patch) | |
tree | d8b06110d84fce783f1cc91aa37155351c655b2c /hsm-command/Main.hs |
Diffstat (limited to 'hsm-command/Main.hs')
-rw-r--r-- | hsm-command/Main.hs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/hsm-command/Main.hs b/hsm-command/Main.hs new file mode 100644 index 0000000..78fa607 --- /dev/null +++ b/hsm-command/Main.hs @@ -0,0 +1,41 @@ +{-# LANGUAGE ImportQualifiedPost #-} +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE TemplateHaskell #-} + +module Main + ( main + ) +where + +import Data.Aeson.TH (defaultOptions, deriveFromJSON, rejectUnknownFields) +import Data.Function ((&)) +import Data.Text (Text) +import Effectful (runEff) +import Effectful.Log qualified as L +import Effectful.Reader.Static (runReader) +import Effectful.Resource (runResource) +import Hsm.Command.Command (commandStream) +import Hsm.Command.Readline (runReadline) +import Hsm.Core.App (launchWithEcho) +import Hsm.Core.Zmq (runServer, send) +import Streamly.Data.Fold (drain) +import Streamly.Data.Stream (fold, mapM) +import Prelude hiding (mapM, takeWhile) + +data Env = Env + { name :: Text + , pubEp :: Text + } + +$(deriveFromJSON defaultOptions {rejectUnknownFields = True} ''Env) + +main :: IO () +main = + launchWithEcho @Env "command" $ \env logger level -> + (commandStream & mapM (send @_ @Env) & fold drain) + & runServer @Env + & L.runLog env.name logger level + & runReader env + & runReadline + & runResource + & runEff |