polytropos-docrecords: Self-documenting extensible records with provenance tracking and CLI generation

[ cli, configuration, data, library, records ] [ Propose Tags ] [ Report a vulnerability ]

Self-documenting extensible records for polytropos, providing configuration schema extraction, JSON/YAML merging with source provenance, and automated CLI parser synthesis via optparse-applicative. . Inspired by and acknowledging Yves Parès's pioneering docrecords package from the porcupine ecosystem, re-architected from scratch on top of Polytropos's high-performance flat array representation (Polytropos.Core.Rep) and compile-time dictionary synthesis (Polytropos.Plugin). . Key Features: . * Extensible documented records (Polytropos.DocRecord.DocRec) with per-field documentation strings. * Tri-state missing value semantics (Polytropos.DocRecord.PossiblyEmpty) distinguishing unconfigured defaults from missing inputs. * Hierarchical provenance tracking (Polytropos.DocRecord.SourceTag) with deterministic override semantics (CLI > YAML > Default). * Automated Markdown schema generation (Polytropos.DocRecord.showDocumentation). * Zero-boilerplate CLI synthesis (Polytropos.DocRecord.parseRecFromCLI) generating optparse-applicative options from record schemas. . Start at the front door module Polytropos.DocRecord for comprehensive documentation and worked examples.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.2
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <2.3), base (>=4.14 && <5), bytestring (>=0.11 && <0.13), containers (>=0.6 && <0.9), optparse-applicative (>=0.17 && <0.20), polytropos-core (>=0.1 && <0.2), polytropos-plugin (>=0.1 && <0.2), primitive (>=0.8 && <1.0), text (>=2.0 && <2.2), unordered-containers (>=0.2.14 && <0.3), yaml (>=0.11 && <0.12) [details]
License (EUPL-1.2 OR Apache-2.0)
Author Nadia Yvette Chambers
Maintainer nadia.yvette.chambers@ik.me
Uploaded by nyc at 2026-10-21T21:34:38Z
Category Configuration, Data, Records, CLI
Home page https://github.com/NadiaYvette/polytropos
Bug tracker https://github.com/NadiaYvette/polytropos/issues
Source repo head: git clone https://github.com/NadiaYvette/polytropos(packages/polytropos-docrecords)
Distributions
Downloads 3 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-10-21 [all 1 reports]

Readme for polytropos-docrecords-0.1.0.2

[back to package description]

polytropos-docrecords

Self-documenting extensible records with provenance tracking and CLI synthesis for polytropos.

Overview

polytropos-docrecords provides self-documenting configuration records where every field carries human-readable documentation, tri-state missing value semantics, and provenance tracking (CLI > YAML > Default).

Inspired by and acknowledging Yves Parès's @docrecords@ package from the Porcupine pipeline framework, re-architected on top of Polytropos's high-performance flat array representation (Polytropos.Core.Rep).

Features

  • DocRec: Extensible documented record type (RecordF DocItem r) backed by Polytropos's \(O(1)\) flat array representation.
  • PossiblyEmpty: Distinguishes unconfigured defaults from missing values.
  • SourceTag: Multi-tier configuration provenance (DefaultSource, YamlSource, CliSource) with automatic precedence overriding.
  • showDocumentation: Formats the record schema into human-readable Markdown tables.
  • fromJSONAs: Decodes JSON/YAML against a default schema, updating only provided fields and marking them with YamlSource.
  • parseRecFromCLI: Synthesizes full optparse-applicative command-line option parsers directly from record schemas with zero boilerplate.

Quick Example

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fplugin=Polytropos.Plugin #-}

import qualified Data.Text.IO as T
import Options.Applicative
import Polytropos
import Polytropos.DocRecord

type ServerConfig =
  '[ "host"     := String
   , "port"     := Int
   , "verbose"  := Bool
   ]

defaultConfig :: DocRec ServerConfig
defaultConfig =
  consDoc (Field @"host") (docField "127.0.0.1" "Listening IP address or hostname")
    $ consDoc (Field @"port") (docField (8080 :: Int) "TCP service port")
    $ consDoc (Field @"verbose") (docField False "Enable debug logging")
    $ emptyDocRec

main :: IO ()
main = do
  -- 1. Print formatted Markdown schema documentation:
  T.putStrLn (showDocumentation defaultConfig)

  -- 2. Inspect individual field values with standard dot notation:
  print (getDocVal defaultConfig.host)
  print (getDocVal defaultConfig.port)

Attribution & Precedents

This package is inspired by Yves Parès's work on docrecords within the porcupine workflow library. While the interface is re-architected to leverage Polytropos's flat contiguous array physics and compile-time dictionary synthesis, the conceptual model of self-documenting records with provenance tracking originates from docrecords.

License

Dual-licensed under EUPL-1.2 OR Apache-2.0.