- Create a new project ini-parser using the simple Stack template:
stack new ini-parser simple
- Open the file src/Main.hs for editing.
- After the initial module header, add the following imports:
import Data.Functor import Control.Applicative import Control.Monad import Data.Map hiding (empty) import Data.Char
- Define the INI file data structure. Represent name-value pairs in each section (variables) as a map of name to values. Both name and values are represented by strings. The sections inside an INI file are a map between the section name and variables for each section:
type Variables = Map String String type Sections = Map String Variables newtype INI = INI Sections
- Start defining the parser. A parser is defined as ...