settings-0.3.0.0: Runtime-editable program settings.

Data.Settings.Section

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

Construct an empty section, no options and no subsections.

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

Construct a section with a single option.

# Observation

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

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.

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

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

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.

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.

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

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.