solidabis-koodihaaste/src/Main.hs

48 lines
1.3 KiB
Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
{-|
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
-}
module Main where
import Control.Monad.App
import Data.Config
import Data.Language
import qualified Data.Text.IO as T
import Network.HTTP.Client.TLS (newTlsManager)
import Options.Generic
import Servant.Client
import Server
-- | The command line endpoint
--
-- Parses only the path to the config file
-- see config.yaml.sample for the format
newtype Cmd = Cmd (FilePath <?> "Config path")
deriving Generic
instance ParseRecord Cmd
-- | The main function
main :: IO ()
main = do
Cmd (Helpful configPath) <- getRecord "koodihaaste"
_config <- readConfigFromFile configPath
manager <- newTlsManager
_languageModel <- buildModel <$> T.readFile (_training _config)
let state = App{..}
_solidabisClient = ClientEnv manager (_solidabisBase _config) Nothing
runAppM state server