blob: 78fa60709f0adc47532c0088325c348e72c6ad0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|