aboutsummaryrefslogtreecommitdiff
path: root/server/src/Thermoprint/Server.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/Thermoprint/Server.hs')
-rw-r--r--server/src/Thermoprint/Server.hs38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/src/Thermoprint/Server.hs b/server/src/Thermoprint/Server.hs
new file mode 100644
index 0000000..bba067d
--- /dev/null
+++ b/server/src/Thermoprint/Server.hs
@@ -0,0 +1,38 @@
1module Thermoprint.Server
2 ( thermoprintServer
3 , module Data.Default
4 ) where
5
6import Data.Default
7import qualified Config.Dyre as Dyre
8
9import System.IO (hPutStrLn, stderr)
10import System.Exit (exitFailure)
11
12import Control.Monad ((<=<))
13
14data Config = Config { dyreError :: Maybe String
15 }
16
17instance Default Config where
18 def = Config { dyreError = Nothing
19 }
20
21thermoprintServer :: Config -> IO ()
22thermoprintServer = Dyre.wrapMain $ Dyre.defaultParams
23 { Dyre.projectName = "thermoprint-server"
24 , Dyre.realMain = realMain <=< handleDyreErrors
25 , Dyre.showError = (\cfg msg -> cfg { dyreError = Just msg })
26 }
27
28handleDyreErrors :: Config -> IO Config
29handleDyreErrors cfg
30 | Just msg <- dyreError cfg = do
31 hPutStrLn stderr msg
32 exitFailure
33 return undefined
34 | otherwise = return cfg
35
36
37realMain :: Config -> IO ()
38realMain _ = undefined