module Thermoprint.Server ( thermoprintServer , module Data.Default ) where import Data.Default import qualified Config.Dyre as Dyre import System.IO (hPutStrLn, stderr) import System.Exit (exitFailure) import Control.Monad ((<=<)) data Config = Config { dyreError :: Maybe String } instance Default Config where def = Config { dyreError = Nothing } thermoprintServer :: Config -> IO () thermoprintServer = Dyre.wrapMain $ Dyre.defaultParams { Dyre.projectName = "thermoprint-server" , Dyre.realMain = realMain <=< handleDyreErrors , Dyre.showError = (\cfg msg -> cfg { dyreError = Just msg }) } handleDyreErrors :: Config -> IO Config handleDyreErrors cfg | Just msg <- dyreError cfg = do hPutStrLn stderr msg exitFailure return undefined | otherwise = return cfg realMain :: Config -> IO () realMain _ = undefined