trivialini-0.5.0.0: Ultra light weight ini file parser
Copyright(c) 2021-2024 Mirko Westermeier
LicenseMIT
Safe HaskellSafe-Inferred
LanguageHaskell2010

Trivialini

Description

Ultra light weight ini file parser

Synopsis

Ini files and data

Consider a simple ini file config.ini like this:

[something]
foo = bar

[something else]
answer = 42
name = Boaty McBoatface

There are two sections (inbetween "[" and "]") defined, "something" and "something else". These sections contain a dictionary of strings each, the keys being some string followed by "=", and anything else until end of the line as values. The leading and trailing spaces in section headers, keys and values are trimmed.

readIniFile :: FilePath -> IO Ini Source #

Read Ini data from a given filename

readIniFileStrings :: FilePath -> IO (Map String (Map String String)) Source #

Like readIniFile, but results in a stringified nested map

Ini data is a Map of Maps

newtype Ini Source #

As ini files consist of sections with a name, each with a list of key-value pairs, A "two-dimensional" Map of Strings seems to be very natural. However, since the formatting of ini files doesn't allow arbitrary arbitrary characters, restricted types are used here, that are thin wrappers around Strings:

Constructors

Ini 

Instances

Instances details
Read Ini Source #

Parsing of Ini strings.

Instance details

Defined in Trivialini

Show Ini Source #

Stringification of Ini data. The result can be parsed again as Ini data.

Instance details

Defined in Trivialini

Methods

showsPrec :: Int -> Ini -> ShowS #

show :: Ini -> String #

showList :: [Ini] -> ShowS #

Eq Ini Source #

Default Eq instance

Instance details

Defined in Trivialini

Methods

(==) :: Ini -> Ini -> Bool #

(/=) :: Ini -> Ini -> Bool #

Simple String Map conversion

toStringMap :: Ini -> Map String (Map String String) Source #

Convert ini data (with restricted types) to nested String Maps.