module Data.Settings.Types
( Option (..)
, Section (..)
, OptName
, SecName
, OptPath
, OptRoute
, SettingsError (..)
, OptionValue (..)
, MonadSettings (..)
)
where
import qualified Data.HashMap.Lazy as M
data Option m = Option
{
optGet :: m String
, optSet :: String -> m (Maybe SettingsError)
, optReset :: m ()
}
data Section m = Section
{ secOpts :: M.HashMap String (Option m)
, secSubs :: M.HashMap String (Section m)
}
type OptName = String
type SecName = String
type OptPath = String
type OptRoute = [String]
data SettingsError
= InvalidPath OptPath
| NoSuchOption OptRoute
| NoSuchSection OptRoute
| NoSuchNode OptRoute
| InvalidValueForType String
| InvalidValue String
class OptionValue v where
readOption :: String -> Maybe v
showOption :: v -> String
typeName :: v -> String
class Monad m => MonadSettings m s | m -> s where
getSettings :: m s
putSettings :: s -> m ()
modifySettings :: (s -> s) -> m ()
getSTree :: m (Section m)