packages feed

app-settings-0.2.0.2: app-settings.cabal

-- Initial app-settings.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                app-settings
version:             0.2.0.2
synopsis:            A library to manage application settings (INI file-like)
description:         
  A library to deal with application settings.
  .
  This library deals with read-write application settings.
  You will have to specify the settings that your application
  uses, their name, types and default values.
  .
  Setting types must implement the 'Read' and 'Show' typeclasses. 
  .
  The settings are saved in a file in an INI-like key-value format
  (without sections).
  .
  Reading and updating settings is done in pure code, the IO
  monad is only used to load settings and save them to disk.
  It is advised for the user to create a module in your project
  holding settings handling.
  .
  You can then declare settings:
  . 
  > fontSize :: Setting Double
  > fontSize = Setting "fontSize" 14
  > 
  > dateFormat :: Setting String
  > dateFormat = Setting "dateFormat" "%x"
  > 
  > backgroundColor :: Setting (Int, Int, Int)
  > backgroundColor = Setting "backcolor" (255, 0, 0)
  .
  Optionally you can declare the list of all your settings,
  in that case the application will also save the default
  values in the configuration file, but commented out:
  .
  > fontSize=16
  > # dateFormat="%x"
  > # backcolor=(255,0,0)
  .
  If you do not specify the list of settings, only the
  first line would be present in the configuration file.
  .
  With an ordinary setting, one row in the configuration file
  means one setting. That setting may of course be a list
  for instance. This setup works very well for shorter lists
  like [1,2,3], however if you have a list of more complex
  items, you will get very long lines and a configuration
  file very difficult to edit by hand.
  .
  For these special cases there is also the 'ListSetting'
  constructor:
  .
  > testList :: Setting [String]
  > testList = ListSetting "testList" ["list1", "list2", "list3"]
  .
  Now the configuration file looks like that:
  .
  > testList_1="list1"
  > testList_2="list2"
  > testList_3="list3"
  .
  Which is much more handy for big lists. An empty list is represented
  like so:
  .
  > testList=
  .
  Once we declared the settings, we can read the configuration
  from disk (and your settings module should export your wrapper
  around the function offered by this library):
  .
  > readResult <- try $ readSettings (AutoFromAppName "test")
  > case readResult of
  > 	Right (conf, GetSetting getSetting) -> do
  > 		let textSize = getSetting textSizeFromWidth
  > 		saveSettings getDefaultConfig (AutoFromAppName "test") conf
  > 	Left (x :: SomeException) -> error "Error reading the config file!"
  .
  'AutoFromAppName' specifies where to save the configuration file.
  And we've already covered the getSetting in this snippet, see 
  the 'readSettings' documentation for further information.

homepage:            https://github.com/emmanueltouzery/app-settings
license:             BSD3
license-file:        LICENSE
author:              Emmanuel Touzery
maintainer:          etouzery@gmail.com
-- copyright:           
category:            Configuration
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

library
  exposed-modules:     Data.AppSettings
  other-modules:       Data.Serialization,
                       Data.AppSettingsInternal
  -- other-extensions:    
  build-depends:       base >=4.6 && <5,
                       mtl >= 2.1 && <2.3,
                       containers == 0.5.*,
                       directory == 1.2.*,
                       text >= 0.10,
                       parsec == 3.1.*
  -- hs-source-dirs:      
  default-language:    Haskell2010
  Ghc-Options:         -Wall

test-suite             tests
  type:                 exitcode-stdio-1.0
  hs-source-dirs: ., tests
  main-is: Tests.hs
  default-language:    Haskell2010
  build-depends:       base,
                       hspec >= 1.8 && <1.10,
                       HUnit >= 1.2 && <1.3,
                       mtl >= 2.1 && <2.3,
                       containers == 0.5.*,
                       directory == 1.2.*,
                       text >= 0.10,
                       parsec == 3.1.*
  Ghc-Options:         -Wall