    -- |
    -- Module    : Data.Ini.Reader
    -- Copyright : 2011-2014 Magnus Therning
    -- License   : BSD3
    --
    -- Parser for configurations.
    module Data.Ini.Reader
        ( parse
        , IniReaderError(..)
        , IniParseResult
        ) where

    import Control.Monad.Except
    import qualified Text.ParserCombinators.Parsec as P

    import Data.Ini.Types
    import Data.Ini.Reader.Internals

    -- | Parser for a configuration contained in a 'String'.
    parse :: String -> IniParseResult Config
    parse :: String -> IniParseResult Config
    parse s :: String
    s = let
            pr :: Either ParseError [IniFile]
    pr = Parsec String () [IniFile]
    -> String -> String -> Either ParseError [IniFile]
    forall s t a.
    Stream s Identity t =>
    Parsec s () a -> String -> s -> Either ParseError a
    P.parse Parsec String () [IniFile]
    iniParser "ini" String
    s
        in case Either ParseError [IniFile]
    pr of
            Left e :: ParseError
    e -> IniReaderError -> IniParseResult Config
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (IniReaderError -> IniParseResult Config)
    -> (String -> IniReaderError) -> String -> IniParseResult Config
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> IniReaderError
    IniParserError (String -> IniParseResult Config)
    -> String -> IniParseResult Config
    forall a b. (a -> b) -> a -> b
    $ ParseError -> String
    forall a. Show a => a -> String
    show ParseError
    e
            Right is :: [IniFile]
    is -> [IniFile] -> IniParseResult Config
    buildConfig [IniFile]
    is