-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Runtime-editable program settings.
--
@package settings
@version 0.1.0.0
module Data.Settings.Persist
-- | Prepare a save action which writes settings into a JSON file. This
-- action defers the work to a separate dedicated thread, and ensures the
-- file isn't saved more than once within the given time interval.
--
-- The action is non-blocking but there is a chance a save is missed if
-- saves are triggered
--
-- You can call the returned action from your UI thread as a reaction to
-- a settings change, without worrying about delay or IO load.
mkSaveSettings :: (TimeUnit t, ToJSON s) => t -> FilePath -> IO (s -> IO ())
-- | Try to load settings from a file.
--
-- If an error occurs, Left a pair is returned. The boolean
-- indicates whether reading the file failed (False) or parsing
-- the content failed (True). The string is an error description.
--
-- If the operation succeeds, Right the loaded settings are
-- returned.
loadSettings :: FromJSON s => FilePath -> IO (Either (Bool, String) s)
module Data.Settings.Types
data Option m
Option :: m String -> (String -> m (Maybe SettingsError)) -> m () -> Option m
optGet :: Option m -> m String
optSet :: Option m -> String -> m (Maybe SettingsError)
optReset :: Option m -> m ()
data Section m
Section :: HashMap String (Option m) -> HashMap String (Section m) -> Section m
secOpts :: Section m -> HashMap String (Option m)
secSubs :: Section m -> HashMap String (Section m)
type OptName = String
type SecName = String
type OptPath = String
type OptRoute = [String]
data SettingsError
InvalidPath :: OptPath -> SettingsError
NoSuchOption :: OptRoute -> SettingsError
NoSuchSection :: OptRoute -> SettingsError
NoSuchNode :: OptRoute -> SettingsError
InvalidValueForType :: String -> SettingsError
InvalidValue :: String -> SettingsError
class OptionValue v
readOption :: OptionValue v => String -> Maybe v
showOption :: OptionValue v => v -> String
typeName :: OptionValue v => v -> String
class Monad m => MonadSettings m s | m -> s
getSettings :: MonadSettings m s => m s
putSettings :: MonadSettings m s => s -> m ()
modifySettings :: MonadSettings m s => (s -> s) -> m ()
getSTree :: MonadSettings m s => m (Section m)
module Data.Settings.Option
mkOptionV :: (Monad m, OptionValue v) => m v -> (v -> m Bool) -> m () -> Option m
mkOptionS :: (MonadSettings m s, OptionValue v) => (s -> v) -> (v -> s -> Maybe s) -> (s -> (Maybe v, s)) -> (v -> m ()) -> Option m
-- | This module provides functions work working with the Section
-- type, i.e. option trees. The style is similar to the APIs for
-- HashMaps and Maps. You can use these functions to
-- construct a custom settings tree UI. Before you do that, try the
-- Data.Settings.Interface module, which may already offer what
-- you need.
module Data.Settings.Section
-- | Construct an empty section, no options and no subsections.
empty :: Section m
-- | Construct a section with a single option.
singleton :: SecName -> Option m -> Section m
-- | Return True if this section contains any options, False
-- otherwise.
hasOpts :: Section m -> Bool
-- | Return True if this section contains any subsections,
-- False otherwise.
hasSubs :: Section m -> Bool
-- | Return True if this section is empty (no options, no
-- subsections), False otherwise.
null :: Section m -> Bool
-- | Return True if an option or a subsection is present at the
-- specified path, False otherwise.
member :: OptRoute -> Section m -> (Bool, Bool)
-- | Return True if an option is present at the specified path,
-- False otherwise.
memberOpt :: OptRoute -> Section m -> Bool
-- | Return True if a subsection is present at the specified path,
-- False otherwise.
memberSub :: OptRoute -> Section m -> Bool
-- | Return Just the section or option at the specified path, or
-- Nothing if this section contains no such path.
lookup :: OptRoute -> Section m -> Maybe (Either (Section m) (Option m))
-- | Return Just the option at the specified path, or Nothing
-- if this section doesn't contain an option at this path.
lookupOpt :: [String] -> Section m -> Maybe (Option m)
-- | Return Just the section at the specified path, or
-- Nothing if this section doesn't contain a subsection at this
-- path.
lookupSub :: [String] -> Section m -> Maybe (Section m)
-- | Add the specified option at the specified path under this section. If
-- the section previously contained an option for this path, the old
-- value is replaced.
insert :: [String] -> Option m -> Section m -> Section m
-- | Remove the option at the specified path, if present. If there is a
-- section under this path, it won't be removed.
deleteOpt :: [String] -> Section m -> Section m
-- | Remove the section at the specified path, if present. If there is an
-- option under this path, it won't be removed.
deleteSub :: [String] -> Section m -> Section m
-- | Remove the option or section at the specified path, if present.
delete :: [String] -> Section m -> Section m
module Data.Settings.Route
-- | Split a path string into its components, if it's a valid path
-- syntactically.
parseRoute :: OptPath -> Maybe OptRoute
-- | Create a string representation of a path, with the parts separated by
-- periods.
showRoute :: OptRoute -> OptPath
module Data.Settings.Interface
-- | TODO
queryR :: MonadSettings m s => OptRoute -> m (Either SettingsError (Either ([SecName], [OptName]) String))
-- | TODO
querySectionR :: MonadSettings m s => OptRoute -> m (Either SettingsError ([SecName], [OptName]))
-- | TODO
queryOptionR :: MonadSettings m s => OptRoute -> m (Either SettingsError String)
-- | TODO
updateOptionR :: MonadSettings m s => OptRoute -> String -> m (Maybe SettingsError)
-- | TODO
resetOptionR :: MonadSettings m s => OptRoute -> m (Maybe SettingsError)
-- | TODO
query :: MonadSettings m s => OptPath -> m (Either SettingsError (Either ([SecName], [OptName]) String))
-- | TODO
querySection :: MonadSettings m s => OptPath -> m (Either SettingsError ([SecName], [OptName]))
-- | TODO
queryOption :: MonadSettings m s => OptPath -> m (Either SettingsError String)
-- | TODO
updateOption :: MonadSettings m s => OptPath -> String -> m (Maybe SettingsError)
-- | TODO
resetOption :: MonadSettings m s => OptPath -> m (Maybe SettingsError)
module Data.Settings