Skip to content

[#450] Add Util.Main module

Ivan Gromakovskii requested to merge gromak/#450-uncaught-exception into master

Description

Problem: we typically apply 2 functions to main: withUtf8 and displayUncaughtException. Maybe one day we'll have something else. So it's a good idea to group them into a helper function to make sure we won't forget one of them and to make it easier to add another customization later. Also we are using our own displayUncaughtException helper right now, but an equivalent function is exposed from the uncaught-exception package.

Solution:

  1. Create Util.Main module with wrapMain that applies both aforementioned wrappers.
  2. Use withDisplayExceptionHandler from uncaught-exception. We prefer it over displayUncaughtException from the same library because it's supposed to work better in multi-threaded applications. We don't have many of them, but we have some (e. g. morley-client).
  3. Update all Main modules accordingly.

Note: this package is not in Stackage LTS yet, but it's in Nightly and will be added to the next major LTS.

Related issue(s)

Resolves #450 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Ivan Gromakovskii

Merge request reports