diff options
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 |