first working commit

This commit is contained in:
nerf van nerfingen 2022-11-08 20:16:34 +01:00
parent 2e2bbcd0d6
commit 0447d72e71
13 changed files with 465 additions and 0 deletions

29
app/Config.hs Normal file
View file

@ -0,0 +1,29 @@
{-# LANGUAGE OverloadedStrings #-}
module Config where
import qualified Toml
import Toml(TomlCodec, (.=))
import qualified Data.Text as T
data Config = Config {
mailDomain :: String
,mailUsername :: String
,mailPassword :: String
,mailTo :: T.Text
,mailFrom :: T.Text
} deriving Show
configCodec :: TomlCodec Config
configCodec = Config
<$> Toml.string "mailDomain" .= mailDomain
<*> Toml.string "mailUser" .= mailUsername
<*> Toml.string "mailPassword" .= mailPassword
<*> Toml.text "mailTo" .= mailTo
<*> Toml.text "mailFrom" .= mailFrom
parseFile :: String -> IO (Either String Config)
parseFile path = do
config <- Toml.decodeFileEither configCodec path
case config of
Left errors -> return $ Left $ unwords $ fmap show errors
Right x -> return $ Right $ x