{"id":16664297,"url":"https://github.com/glguy/config-schema","last_synced_at":"2025-04-09T19:04:25.096Z","repository":{"id":20644527,"uuid":"90414409","full_name":"glguy/config-schema","owner":"glguy","description":"Self-documenting, combinator constructed configuration schemas","archived":false,"fork":false,"pushed_at":"2023-11-21T16:51:00.000Z","size":132,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-08T20:13:47.713Z","etag":null,"topics":["configuration","haskell","schema"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glguy.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-05T20:37:41.000Z","updated_at":"2024-05-29T18:56:58.213Z","dependencies_parsed_at":"2022-07-26T09:32:11.276Z","dependency_job_id":"1b7dc8ad-e389-4a9c-b1d0-c2b27835c956","html_url":"https://github.com/glguy/config-schema","commit_stats":{"total_commits":111,"total_committers":2,"mean_commits":55.5,"dds":"0.49549549549549554","last_synced_commit":"09324793bfc3bf3507b793e2db05d48bbff59a35"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glguy%2Fconfig-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glguy%2Fconfig-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glguy%2Fconfig-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glguy%2Fconfig-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glguy","download_url":"https://codeload.github.com/glguy/config-schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248095036,"owners_count":21046770,"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":["configuration","haskell","schema"],"created_at":"2024-10-12T10:44:27.959Z","updated_at":"2025-04-09T19:04:25.068Z","avatar_url":"https://github.com/glguy.png","language":"Haskell","readme":"config-schema\n=============\n\n[![Hackage](https://img.shields.io/hackage/v/config-schema.svg)](https://hackage.haskell.org/package/config-schema)\n\nLive Demo\n--------\n\nThe config-value and config-schema packages are available in a [live demo](https://glguy.net/config-demo/).\n\nAbout\n--------\n\nThis package allows the user to define configuration schemas suitable for\nmatching against configuration files written in the\n[config-value](https://hackage.haskell.org/package/config-value) format.\nThese schemas allow the user to extract an arbitrary Haskell value from\nan interpretation of a configuration file. It also allows the user to\nprogramatically generate documentation for the configuration files\naccepted by the loader.\n\n```haskell\n{-# Language OverloadedStrings, ApplicativeDo #-}\nmodule Example where\n\nimport qualified Data.Text as Text\nimport           Data.Text (Text)\nimport           Data.Monoid ((\u003c\u003e))\nimport           Data.Functor.Alt ((\u003c!\u003e))\nimport           Data.List.NonEmpty (NonEmpty)\n\nimport           Config\nimport           Config.Schema\n\nexampleFile :: Text\nexampleFile =\n  \" name: \\\"Johny Appleseed\\\" \\n\\\n  \\ age : 99                  \\n\\\n  \\ happy: yes                \\n\\\n  \\ kids:                     \\n\\\n  \\   * name: \\\"Bob\\\"         \\n\\\n  \\   * name: \\\"Tom\\\"         \\n\"\n\nexampleValue :: Value Position\nRight exampleValue = parse exampleFile\n\nexampleSpec :: ValueSpec Text\nexampleSpec = sectionsSpec \"\" $\n  do name  \u003c- reqSection  \"name\" \"Full name\"\n     age   \u003c- reqSection  \"age\"  \"Age of user\"\n     happy \u003c- optSection' \"happy\" yesOrNo\n              \"Current happiness status\"\n     kids  \u003c- reqSection' \"kids\"  (oneOrList kidSpec)\n              \"All children's names\"\n\n     return $\n       let happyText = case happy of Just True  -\u003e \" and is happy\"\n                                     Just False -\u003e \" and is not happy\"\n                                     Nothing    -\u003e \" and is private\"\n\n       in name \u003c\u003e \" is \" \u003c\u003e Text.pack (show (age::Integer)) \u003c\u003e\n             \" years old and has kids \" \u003c\u003e\n             Text.intercalate \", \" kids \u003c\u003e\n             happyText\n\nkidSpec :: ValueSpec Text\nkidSpec = sectionsSpec \"kid\" (reqSection \"name\" \"Kid's name\")\n\n\n-- | Matches the 'yes' and 'no' atoms\nyesOrNo :: ValueSpec Bool\nyesOrNo = True  \u003c$ atomSpec \"yes\" \u003c!\u003e\n          False \u003c$ atomSpec \"no\"\n\n\nprintDoc :: IO ()\nprintDoc = print (generateDocs exampleSpec)\n-- *Example\u003e printDoc\n-- Top-level configuration file fields:\n--     name: REQUIRED text\n--        Full name\n--     age: REQUIRED integer\n--        Age of user\n--     happy: `yes` or `no`\n--        Current happiness status\n--     kids: REQUIRED kid or list of kid\n--        All children\n--\n-- kid\n--     name: REQUIRED text\n--        Kid's name\n\nexample :: Either (NonEmpty (LoadError Position)) Text\nexample = loadValue exampleSpec exampleValue\n-- *Example\u003e exampleVal\n-- Right \"Johny Appleseed is 99 years old and has kids Bob, Tom and is happy\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglguy%2Fconfig-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglguy%2Fconfig-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglguy%2Fconfig-schema/lists"}