mirror of
https://github.com/input-output-hk/foliage.git
synced 2024-12-01 21:02:16 +03:00
Remove leftover file
This commit is contained in:
parent
6d346c5212
commit
4ff84f10db
@ -1,48 +0,0 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module Foliage.Config
|
||||
( Config (..),
|
||||
Source (..),
|
||||
readConfig,
|
||||
)
|
||||
where
|
||||
|
||||
import Data.List.NonEmpty as NE
|
||||
import Data.Text (Text)
|
||||
import Toml (TomlCodec, (.=)) -- add 'TomlBiMap' and 'Key' here optionally
|
||||
import Toml qualified
|
||||
|
||||
newtype Config = Config
|
||||
{ configSources :: [Source]
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
configCodec :: TomlCodec Config
|
||||
configCodec =
|
||||
Config
|
||||
<$> Toml.list sourceCodec "sources" .= configSources
|
||||
|
||||
data Source = Source
|
||||
{ sourceUrl :: Text,
|
||||
sourceSubdirs :: [Text]
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
sourceCodec :: TomlCodec Source
|
||||
sourceCodec =
|
||||
Source
|
||||
<$> Toml.text "url" .= sourceUrl
|
||||
<*> subdirsCodec .= sourceSubdirs
|
||||
|
||||
subdirsCodec :: TomlCodec [Text]
|
||||
subdirsCodec =
|
||||
Toml.dimap
|
||||
NE.nonEmpty
|
||||
(maybe [] toList)
|
||||
(Toml.dioptional $ Toml.arrayNonEmptyOf Toml._Text "subdirs")
|
||||
|
||||
readConfig :: FilePath -> IO (Either String Config)
|
||||
readConfig fp = do
|
||||
tomlRes <- Toml.decodeFileEither configCodec fp
|
||||
return $ case tomlRes of
|
||||
Left e -> Left (show e)
|
||||
Right settings -> Right settings
|
Loading…
Reference in New Issue
Block a user