O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create a new project ini-parser using the simple Stack template:
        stack new ini-parser simple
  1. Open the file src/Main.hs for editing.
  2. 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
  1. 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
  1. Start defining the parser. A parser is defined as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required