2019-10-15 23:11:07 +03:00
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
|
|
|
{-# LANGUAGE TypeOperators #-}
|
2019-10-15 23:47:32 +03:00
|
|
|
{-|
|
|
|
|
Module : Main
|
|
|
|
Description : The main module
|
|
|
|
Copyright : (c) Mats Rauhala, 2019
|
|
|
|
License : BSD3
|
|
|
|
Maintainer : mats.rauhala@iki.fi
|
|
|
|
Stability : experimental
|
|
|
|
Portability : POSIX
|
|
|
|
|
|
|
|
|
|
|
|
The main access point for the koodihaaste
|
|
|
|
-}
|
2019-10-15 19:47:54 +03:00
|
|
|
module Main where
|
|
|
|
|
2019-10-15 22:52:03 +03:00
|
|
|
import Control.Monad.App
|
|
|
|
import Data.Config
|
2019-10-15 23:11:07 +03:00
|
|
|
import Data.Language
|
|
|
|
import qualified Data.Text.IO as T
|
2019-10-15 22:52:03 +03:00
|
|
|
import Network.HTTP.Client.TLS (newTlsManager)
|
2019-10-15 23:11:07 +03:00
|
|
|
import Options.Generic
|
2019-10-15 22:52:03 +03:00
|
|
|
import Servant.Client
|
|
|
|
import Server
|
2019-10-15 23:11:07 +03:00
|
|
|
|
2019-10-15 23:47:32 +03:00
|
|
|
-- | The command line endpoint
|
|
|
|
--
|
|
|
|
-- Parses only the path to the config file
|
|
|
|
-- see config.yaml.sample for the format
|
2019-10-15 23:11:07 +03:00
|
|
|
newtype Cmd = Cmd (FilePath <?> "Config path")
|
|
|
|
deriving Generic
|
|
|
|
|
|
|
|
instance ParseRecord Cmd
|
2019-10-15 22:52:03 +03:00
|
|
|
|
2019-10-15 23:47:32 +03:00
|
|
|
-- | The main function
|
2019-10-15 19:47:54 +03:00
|
|
|
main :: IO ()
|
2019-10-15 22:52:03 +03:00
|
|
|
main = do
|
2019-10-15 23:11:07 +03:00
|
|
|
Cmd (Helpful configPath) <- getRecord "koodihaaste"
|
|
|
|
_config <- readConfigFromFile configPath
|
2019-10-15 22:52:03 +03:00
|
|
|
manager <- newTlsManager
|
|
|
|
_languageModel <- buildModel <$> T.readFile (_training _config)
|
|
|
|
let state = App{..}
|
|
|
|
_solidabisClient = ClientEnv manager (_solidabisBase _config) Nothing
|
|
|
|
runAppM state server
|