settings-0.3.0.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 route, or Nothing if this section contains no such route.

lookupOpt :: OptRoute -> Section m -> Maybe (Option m) Source #

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

lookupSub :: OptRoute -> Section m -> Maybe (Section m) Source #

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

Modification

insertOpt Source #

Arguments

:: OptRoute

Route 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 route under this section. If the section previously contained an option for this route, the old value is replaced.

insertSub Source #

Arguments

:: OptRoute

Route 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 route under this section. If the section previously contained a subsection for this route, the old value is replaced.

deleteOpt :: OptRoute -> Section m -> Section m Source #

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

deleteSub :: OptRoute -> Section m -> Section m Source #

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

delete :: OptRoute -> Section m -> Section m Source #

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