e9571-config-reader-haskell: Automatically read config.json from the current directory

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Zero-configuration JSON config loader


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.0, 0.1.0.1, 0.1.0.2
Change log None available
Dependencies aeson (>=2.0 && <2.3), base (>=4.14 && <5), bytestring, directory, e9571-config-reader-haskell [details]
License MIT
Author e9571
Maintainer 95714623@qq.com
Category Configuration
Home page https://github.com/e9571/e9571-config-reader-haskell
Uploaded by e9571 at 2025-11-26T01:15:27Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for e9571-config-reader-haskell-0.1.0.0

[back to package description]

e9571-config-reader-haskell

A tiny, zero-configuration Haskell library that instantly reads a config.json file from the current working directory.

Out-of-the-box, no setup required.
Just drop a config.json file next to your executable and start using the library — it just works.

Usage (two steps)

  1. Create a config.json file in the same directory as your program:

    {
      "host": "127.0.0.1",
      "port": 8080
    }
    
  2.    {-# LANGUAGE OverloadedStrings #-}
       
       import E9571.ConfigReader
       import Data.Aeson
       
       data Config = Config { host :: String, port :: Int } deriving Show
       
       instance FromJSON Config where
           parseJSON = withObject "Config" $ \o -> Config
               <$> o .: "host"
               <*> o .: "port"
       
       main :: IO ()
       main = do
           cfg <- loadConfigOrDie :: IO Config   -- automatically reads ./config.json
           putStrLn $ "Server starting at " ++ host cfg ++ ":" ++ show (port cfg)
       
           
    
    
    
    
    

Features

Installation

cabal install e9571-config-reader-haskell

Source: https://github.com/e9571/e9571-config-reader-haskell Hackage: https://hackage.haskell.org/package/e9571-config-reader-haskell

Enjoy the simplicity!