2019-05-16 22:39:06 +03:00
|
|
|
{-# LANGUAGE AllowAmbiguousTypes #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
2019-05-15 22:12:08 +03:00
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
module Main where
|
2019-05-15 22:12:08 +03:00
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
import Control.Monad
|
|
|
|
import qualified Data.Map as Map
|
|
|
|
import qualified Data.Set as Set
|
2019-05-15 22:12:08 +03:00
|
|
|
import Hydra.Prelude
|
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
import qualified Free as Free
|
2019-05-17 19:23:35 +03:00
|
|
|
import Types
|
2019-05-18 11:59:22 +03:00
|
|
|
import qualified FTL as FTL
|
2019-05-16 22:39:06 +03:00
|
|
|
import qualified Church as Church
|
|
|
|
import qualified Hydra.Domain as D
|
|
|
|
import qualified Hydra.Runtime as R
|
2019-09-10 22:08:33 +03:00
|
|
|
import qualified Hydra.Framework.RLens as RLens
|
2019-05-15 22:12:08 +03:00
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
data Method = FT | FreeM | ChurchM
|
|
|
|
deriving (Show, Read, Eq, Ord)
|
2019-05-15 22:12:08 +03:00
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
data Config = Config
|
2019-05-17 19:23:35 +03:00
|
|
|
{ useLog :: Bool
|
|
|
|
, method :: Method
|
|
|
|
, appConfig :: AppConfig
|
2019-05-15 22:12:08 +03:00
|
|
|
}
|
2019-05-16 22:39:06 +03:00
|
|
|
deriving (Show, Read, Eq, Ord)
|
2019-05-15 22:12:08 +03:00
|
|
|
|
|
|
|
loggerCfg :: D.LoggerConfig
|
|
|
|
loggerCfg = D.LoggerConfig
|
|
|
|
{ D._format = "$prio $loggername: $msg"
|
|
|
|
, D._level = D.Debug
|
|
|
|
, D._logFilePath = ""
|
|
|
|
, D._logToConsole = True
|
|
|
|
, D._logToFile = False
|
|
|
|
}
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2019-05-17 19:40:11 +03:00
|
|
|
|
2019-05-16 22:39:06 +03:00
|
|
|
cfgStr <- readFile "meteor_counter.cfg"
|
|
|
|
let cfg :: Config = read $ toString cfgStr
|
|
|
|
|
|
|
|
putStrLn @String $ "Method: " <> show (method cfg)
|
2019-05-15 22:12:08 +03:00
|
|
|
|
2019-09-13 21:41:21 +03:00
|
|
|
let mbLoggerCfg = if useLog cfg then Just loggerCfg else Nothing
|
|
|
|
|
|
|
|
R.withAppRuntime mbLoggerCfg $ \appRt -> do
|
|
|
|
when (method cfg == FT)
|
|
|
|
$ FTL.scenario (appRt ^. RLens.coreRuntime)
|
|
|
|
$ appConfig cfg
|
|
|
|
|
|
|
|
when (method cfg == FreeM)
|
|
|
|
$ Free.scenario appRt
|
|
|
|
$ appConfig cfg
|
|
|
|
|
|
|
|
when (method cfg == ChurchM)
|
|
|
|
$ Church.scenario appRt
|
|
|
|
$ appConfig cfg
|