ConfigFile-1.1.4: Configuration file reading & writing

Safe Haskell | None
Language | Haskell98

Data.ConfigFile.Monadic

Contents

- Overview

Synopsis

- simpleAccess :: MonadError CPError m => SectionSpec -> OptionSpec -> ConfigParser -> m String
- interpolatingAccess :: MonadError CPError m => Int -> SectionSpec -> OptionSpec -> ConfigParser -> m String
- readfile :: MonadError CPError m => FilePath -> ConfigParser -> IO (m ConfigParser)
- readhandle :: MonadError CPError m => Handle -> ConfigParser -> IO (m ConfigParser)
- readstring :: MonadError CPError m => String -> ConfigParser -> m ConfigParser
- has_section :: SectionSpec -> ConfigParser -> Bool
- options :: MonadError CPError m => SectionSpec -> ConfigParser -> m [OptionSpec]
- has_option :: SectionSpec -> OptionSpec -> ConfigParser -> Bool
- items :: MonadError CPError m => SectionSpec -> ConfigParser -> m [(OptionSpec, String)]
- set :: MonadError CPError m => SectionSpec -> OptionSpec -> String -> ConfigParser -> m ConfigParser
- setshow :: (Show a, MonadError CPError m) => SectionSpec -> OptionSpec -> a -> ConfigParser -> m ConfigParser
- remove_option :: MonadError CPError m => SectionSpec -> OptionSpec -> ConfigParser -> m ConfigParser
- add_section :: MonadError CPError m => SectionSpec -> ConfigParser -> m ConfigParser
- remove_section :: MonadError CPError m => SectionSpec -> ConfigParser -> m ConfigParser

# Overview

This module reexports a slightly different version of the standard API which makes it more convenient for chaining monadically. Everywhere a `ConfigParser` was the first argument in a function in the standard API, it is now the last. This lets you rewrite

    do let cp = emptyCP
       cp <- add_section cp "sect1"
       cp <- set cp "sect1" "opt1" "foo"
       cp <- set cp "sect1" "opt2" "bar"
       options cp "sect1"

as

    return emptyCP >>=
     add_section "sect1" >>=
     set "sect1" "opt1" "foo" >>=
     set "sect1" "opt2" "bar" >>=
     options "sect1"

which may be more elegant in some cases. A future development might be to chain the `ConfigParser` implicitly with a state monad, which would be yet more elegant.

simpleAccess :: MonadError CPError m => SectionSpec -> OptionSpec -> ConfigParser -> m String Source #

interpolatingAccess :: MonadError CPError m => Int -> SectionSpec -> OptionSpec -> ConfigParser -> m String Source #

readfile :: MonadError CPError m => FilePath -> ConfigParser -> IO (m ConfigParser) Source #

readhandle :: MonadError CPError m => Handle -> ConfigParser -> IO (m ConfigParser) Source #

readstring :: MonadError CPError m => String -> ConfigParser -> m ConfigParser Source #

has_section :: SectionSpec -> ConfigParser -> Bool Source #

options :: MonadError CPError m => SectionSpec -> ConfigParser -> m [OptionSpec] Source #

has_option :: SectionSpec -> OptionSpec -> ConfigParser -> Bool Source #

items :: MonadError CPError m => SectionSpec -> ConfigParser -> m [(OptionSpec, String)] Source #

set :: MonadError CPError m => SectionSpec -> OptionSpec -> String -> ConfigParser -> m ConfigParser Source #

setshow :: (Show a, MonadError CPError m) => SectionSpec -> OptionSpec -> a -> ConfigParser -> m ConfigParser Source #

remove_option :: MonadError CPError m => SectionSpec -> OptionSpec -> ConfigParser -> m ConfigParser Source #

add_section :: MonadError CPError m => SectionSpec -> ConfigParser -> m ConfigParser Source #

remove_section :: MonadError CPError m => SectionSpec -> ConfigParser -> m ConfigParser Source #