settings-0.2.2.0: Runtime-editable program settings.

Safe HaskellSafe
LanguageHaskell2010

Data.Settings.Section

Contents

Description

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.

Synopsis

Construction

empty :: Section m Source

Construct an empty section, no options and no subsections.

singleton :: SecName -> Option m -> Section m Source

Construct a section with a single option.

Observation

hasOpts :: Section m -> Bool Source

Return True if this section contains any options, False otherwise.

hasSubs :: Section m -> Bool Source

Return True if this section contains any subsections, False otherwise.

null :: Section m -> Bool Source

Return True if this section is empty (no options, no subsections), False otherwise.

member :: OptRoute -> Section m -> (Bool, Bool) Source

Return True if an option or a subsection is present at the specified path, False otherwise.

memberOpt :: OptRoute -> Section m -> Bool Source

Return True if an option is present at the specified path, False otherwise.

memberSub :: OptRoute -> Section m -> Bool Source

Return True if a subsection is present at the specified path, False otherwise.

lookup :: OptRoute -> Section m -> Maybe (Either (Section m) (Option m)) Source

Return Just the section or option at the specified path, or Nothing if this section contains no such path.

lookupOpt :: [String] -> Section m -> Maybe (Option m) Source

Return Just the option at the specified path, or Nothing if this section doesn't contain an option at this path.

lookupSub :: [String] -> Section m -> Maybe (Section m) Source

Return Just the section at the specified path, or Nothing if this section doesn't contain a subsection at this path.

Modification

insert :: [String] -> Option m -> Section m -> Section m Source

Alias for insertOpt.

insertOpt Source

Arguments

:: [String]

Path at which to place the option

-> Option m

Option to insert

-> Section m

Root section under which to insert

-> 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.

insertSub Source

Arguments

:: [String]

Path at which to place the subsection

-> Section m

Subsection to insert

-> Section m

Root section under which to insert

-> Section m 

Add the specified subsection at the specified path under this section. If the section previously contained a subsection for this path, the old value is replaced.

deleteOpt :: [String] -> Section m -> Section m Source

Remove the option at the specified path, if present. If there is a section under this path, it won't be removed.

deleteSub :: [String] -> Section m -> Section m Source

Remove the section at the specified path, if present. If there is an option under this path, it won't be removed.

delete :: [String] -> Section m -> Section m Source

Remove the option or section at the specified path, if present.