hslua-0.3.9: A Lua language interpreter embedding in Haskell

Portabilityportable, ffi
Stabilityalpha
Maintainerbenjamin.geer@gmail.com
Safe HaskellSafe-Inferred

Scripting.Lua.ConfigFile

Description

Reads configuration files written in Lua. See http://www.lua.org/ for more details.

Synopsis

Documentation

data Config

Represents an open configuration file.

openConfig :: FilePath -> IO Config

Opens a config file and returns an opaque reference to the file. You must close this reference using close when you're done reading the file.

closeConfig :: Config -> IO ()

Closes a configuration file.

getBool :: Config -> String -> IO Bool

Returns a boolean value from a configuration file. Returns False if the value is not defined in the file. Example:

 someVal = true

getString :: Config -> String -> IO String

Returns a string value from a configuration file. Returns the empty string if the value is not defined in the file. Example:

 someVal = "foo"

getInt :: Config -> String -> IO (Maybe Int)

Returns an integer value from a configuration file. Example:

 someVal = 2

getDouble :: Config -> String -> IO (Maybe Double)

Returns a double value from a configuration file. Example:

 someVal = 3.1415926

getList :: Config -> String -> IO [String]

Returns a list of strings (i.e. a Lua table in which the keys are integers and the values are strings) from a configuration file. Example:

 someVal = { "foo", "bar", "baz" }

getNestedLists :: Config -> String -> IO [[String]]

Returns a list of lists, i.e. a Lua table of tables. In the outer table, the keys are integers and the values are tables, and in the inner tables, the keys are integers and the values are strings. Example:

 someVal = {
    { "foo one", "foo two", "foo three" },
    { "bar one", "bar two", "bar three" }
 }

getAssocList :: Config -> String -> IO [(String, String)]

Returns an association list, i.e. a Lua table in which the keys and values are strings. Example:

 someVal = {
    one = "foo",
    two = "bar",
    three = "baz"
 }

getListOfAssocLists :: Config -> String -> IO [[(String, String)]]

Returns a list of association lists, i.e. a Lua table of tables. In the outer table, the keys are integers and the values are tables, and in the inner tables, the keys and values are strings. Example:

 someVal = {
    {
       foo = "aaa",
       bar = "bbb",
       baz = "ccc"
    },
    {
       foo = "ddd",
       bar = "eee",
       baz = "fff"
    }
 }

getNestedAssocLists :: Config -> String -> IO [(String, [(String, String)])]

Returns an association list of association lists, i.e. a Lua table of tables. In the outer table, the keys are strings and the values are tables, and in the inner tables, the keys and values are strings. Example:

 someVal = {
    something = {
       foo = "aaa",
       bar = "bbb",
       baz = "ccc"
    },
    somethingElse = {
       foo = "ddd",
       bar = "eee",
       baz = "fff"
    }
 }

data ConfigFileException

Thrown when an error occurs in reading a configuration file.

Instances