    {-# LANGUAGE ImportQualifiedPost #-}

    {- |
    Module    : Data.Ini.Types
    Copyright : 2011-2014 Magnus Therning
    License   : BSD3
    -}
    module Data.Ini.Types where

    import Control.Arrow (second)
    import Data.Map qualified as M

    type Config = M.Map SectionName Section

    type SectionName = String
    type Section = M.Map OptionName OptionValue

    type OptionName = String
    type OptionValue = String

    -- useful since Map doesn't have any Serial instance
    cfgFromList :: [(SectionName, [(OptionName, OptionValue)])] -> Config
    cfgFromList :: [(SectionName, [(SectionName, SectionName)])] -> Config
    cfgFromList = [(SectionName, Section)] -> Config
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList ([(SectionName, Section)] -> Config)
    -> ([(SectionName, [(SectionName, SectionName)])]
        -> [(SectionName, Section)])
    -> [(SectionName, [(SectionName, SectionName)])]
    -> Config
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((SectionName, [(SectionName, SectionName)])
     -> (SectionName, Section))
    -> [(SectionName, [(SectionName, SectionName)])]
    -> [(SectionName, Section)]
    forall a b. (a -> b) -> [a] -> [b]
    map (([(SectionName, SectionName)] -> Section)
    -> (SectionName, [(SectionName, SectionName)])
    -> (SectionName, Section)
    forall b c d. (b -> c) -> (d, b) -> (d, c)
    forall (a :: * -> * -> *) b c d.
    Arrow a =>
    a b c -> a (d, b) (d, c)
    second [(SectionName, SectionName)] -> Section
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList)

    cfgToList :: Config -> [(SectionName, [(OptionName, OptionValue)])]
    cfgToList :: Config -> [(SectionName, [(SectionName, SectionName)])]
    cfgToList = Map SectionName [(SectionName, SectionName)]
    -> [(SectionName, [(SectionName, SectionName)])]
    forall k a. Map k a -> [(k, a)]
    M.toList (Map SectionName [(SectionName, SectionName)]
     -> [(SectionName, [(SectionName, SectionName)])])
    -> (Config -> Map SectionName [(SectionName, SectionName)])
    -> Config
    -> [(SectionName, [(SectionName, SectionName)])]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Section -> [(SectionName, SectionName)])
    -> Config -> Map SectionName [(SectionName, SectionName)]
    forall a b k. (a -> b) -> Map k a -> Map k b
    M.map Section -> [(SectionName, SectionName)]
    forall k a. Map k a -> [(k, a)]
    M.toList