{"id":19888619,"url":"https://github.com/postgrest/configurator-pg","last_synced_at":"2025-12-11T23:22:46.128Z","repository":{"id":34916489,"uuid":"189302655","full_name":"PostgREST/configurator-pg","owner":"PostgREST","description":"Reduced parser for configurator-ng config files","archived":false,"fork":false,"pushed_at":"2024-03-07T01:01:09.000Z","size":49,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-18T03:45:21.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PostgREST.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-05-29T21:38:15.000Z","updated_at":"2024-01-14T12:44:53.000Z","dependencies_parsed_at":"2024-01-07T11:25:59.786Z","dependency_job_id":"428a919f-fa4d-4be0-9974-096a5cee603a","html_url":"https://github.com/PostgREST/configurator-pg","commit_stats":null,"previous_names":["robx/configurator-pg"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fconfigurator-pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fconfigurator-pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fconfigurator-pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PostgREST%2Fconfigurator-pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PostgREST","download_url":"https://codeload.github.com/PostgREST/configurator-pg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224324468,"owners_count":17292521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T18:07:43.995Z","updated_at":"2025-12-11T23:22:46.089Z","avatar_url":"https://github.com/PostgREST.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## What is this?\n\nThis is a simplified version of the resting\n[configurator-ng](https://github.com/lpsmith/configurator-ng),\naimed particularly to offer users of configurator-ng such as\n[PostgREST](postgrest.org) an easy path to migrate to\na package that compiles with modern GHC versions and that\ncontinues to read existing configuration files.\n\n## Changes\n\nconfigurator-pg skips some of configurator-ng's features, and\nchanges the API in other places:\n\n  * No configuration file reloading.\n  * Simplified parsing API:\n    - There is no type-class based value parsing; you need\n      to supply explicit value parsers.\n    - There's only `load` to read and evaluate a configuration file,\n      and `runParser` to extract configuration values.\n  * Simpler error handling and improved logging of parse errors.\n  * Simplified handling of configuration subsets. There's `subassocs`\n    and the unit tests pass, but the author didn't attempt to\n    understand the original implementation fully.\n\n## Credits\n\nThe original configurator-ng is due to MailRank, Inc., Bryan\nO'Sullivan and Leon P Smith.\n\nThe low-level parser (Data.Configurator.Syntax) was initially\nmostly unchanged, but has since been rewritten with Megaparsec\nfor better error messages. The evaluation (Data.Configurator.Load)\nis still close to the original. The high-level parser\n(Data.Configurator.Parser) is original.\n\n## File format\n\nIn short, the file format supports:\n\n* A simple but flexible configuration language that supports several\n  of the most commonly needed types of data, along with\n  interpolation of strings from the configuration or the system\n  environment (e.g. `$(HOME)`).\n\n* An `import` directive allows the configuration of a complex\n  application to be split across several smaller files, or common\n  configuration data to be shared across several applications.\n\nThe format is more fully documented in the packages\n[configurator](https://hackage.haskell.org/package/configurator) and\n[configurator-ng](https://hackage.haskell.org/package/configurator-ng).\n\nHere's an example:\n\n```\n# listen address\nhostname = \"localhost\"\nport = 8000\n\nlogdir = \"$(HOME)/logs\"\nlogfile = \"$(logdir)/log.txt\"\nloglevels = [1, 4, 5]\n\nusers {\n  alice = \"alice@example.com\"\n  bob   = \"bob@example.com\"\n}\n\n# passwords.txt might contain\n#   alice = \"12345\"\n#   bob   = \"sesame\"\npasswords {\n  import \"secrets/passwords.txt\"\n}\n```\n\n## Usage\n\nThe following code can be used to parse the example above.\n\n```\nimport Data.Configurator\n\ndata Settings = Settings\n  { hostname  :: Text\n  , port      :: Int\n  , logfile   :: Maybe FilePath\n  , loglevels :: Maybe [Int]\n  , users     :: [(Text, Text)]\n  , passwords :: [(Text, Text)]\n  }\n\nsettingsParser :: Parser Config Settings\nsettingsParser =\n  Settings\n    \u003c$\u003e required \"hostname\" string\n    \u003c*\u003e (Maybe.withDefault 1234 \u003c$\u003e optional \"port\" int)\n    \u003c*\u003e optional \"logfile\" (pack \u003c$\u003e string)\n    \u003c*\u003e optional \"loglevels\" (list int)\n    \u003c*\u003e subassocs \"users\" string\n    \u003c*\u003e subassocs \"passwords\" string\n\nloadSettings :: IO Settings\nloadSettings = do\n  cfg \u003c- load \"settings.cfg\"\n  case runParser settingsParser cfg of\n    Left err       -\u003e die $ \"reading config: \" \u003c\u003e err\n    Right settings -\u003e return settings\n```\n\nThough note that for no apparent reason, `subassocs`\nreturns the full key, whence the parsed list of users\nwill be\n\n```\n    [ (\"users.alice\", \"alice@example.com\")\n    , (\"users.bob\", \"bob@example.com\")\n    ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrest%2Fconfigurator-pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostgrest%2Fconfigurator-pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrest%2Fconfigurator-pg/lists"}