Changing Things when Things need a changin'
Changing Program
The original design of core-program's configure
function had you specifying the initial value of the top-level application state τ. This has proved to be unwieldly, as it seems we all want to do things like querying the options and arguments in order to compose that starting value.
A number of us simultaneously his the same question, and independently came up with the same solution: enable the developer to change their Program τ to Program υ , where υ is the new top-level application state type. The new function enabling this is changeProgram
. This means you can start your program in Program None and then switch to Program Settings or Program This,That, or TheOtherThing once you've worked out which way you're going (this latter example has emerged as a way to give each different command in your program its own top-level type. Interesting!). Thanks to @guaraqe and @dmvianna for validating this use case and approving the implementation!
Changing Process
Some internal surgery and re-arranging allows us to introduce execProcess_
, a function which will result in an exec(2) system call to replace your running program with a new one. It's important to use this helper function (rather than calling the Posix functions in unix directly) so that you can be confident that output logging and telemetry have been sent before switching to the the new binary.
While the trailing underscore convention is appropriate here, the function previously named execProcess
used for running a child and reading its output was misplaced, and so we've renamed it to readProcess
. Not sure what we were thinking there, but the underlying name from upstream is clearly better and so we return to presenting our wrapper in the same style.
Bug fixes and general improvements
Introduce a new pair of functions for constructing Configs that allow adding top-level precis descriptions for --help
output, simpleConfig'
and complexConfig'
, each taking an additional parameter supplying the descriptive text to be printed above the "Usage:" section. It's just cosmetic, but we've been wanting to add this for a long time; makes for a nice touch to have a short description of the program before getting into the nitty-gritty of command-line options and arguments.
- Add top-level program descriptions to help by @istathar in #170
- Use stackage lts-20.10 at GHC 9.2.5 by @justinlynn in #166
- Fix documentation by @istathar in #167
New Contributors
- @justinlynn made their first contribution in #166
Full Changelog: core-program-0.6.2.2...core-program-0.6.5.0