Option parser

This commit is contained in:
Mats Rauhala 2019-10-15 23:11:07 +03:00
parent 7588229fff
commit 10d767157c
2 changed files with 16 additions and 4 deletions

View File

@ -32,6 +32,7 @@ executable koodihaaste
build-depends: base >=4.12 && <4.13 build-depends: base >=4.12 && <4.13
, servant , servant
, servant-server , servant-server
, optparse-generic
, servant-client , servant-client
, servant-client-core , servant-client-core
, text , text

View File

@ -1,17 +1,28 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}
module Main where module Main where
import Control.Monad.App import Control.Monad.App
import Data.Config import Data.Config
import Data.Language
import qualified Data.Text.IO as T
import Network.HTTP.Client.TLS (newTlsManager) import Network.HTTP.Client.TLS (newTlsManager)
import Options.Generic
import Servant.Client import Servant.Client
import Server import Server
import qualified Data.Text.IO as T
import Data.Language newtype Cmd = Cmd (FilePath <?> "Config path")
deriving Generic
instance ParseRecord Cmd
main :: IO () main :: IO ()
main = do main = do
_config <- readConfigFromFile "config.yaml" Cmd (Helpful configPath) <- getRecord "koodihaaste"
_config <- readConfigFromFile configPath
manager <- newTlsManager manager <- newTlsManager
_languageModel <- buildModel <$> T.readFile (_training _config) _languageModel <- buildModel <$> T.readFile (_training _config)
let state = App{..} let state = App{..}