pinned-warnings: Preserve warnings in a GHCi session

[ bsd3, development, library, utility ] [ Propose Tags ]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,,,,
Change log
Dependencies base (>=4.16.0 && <5), bytestring (>=0.11.3 && <0.13), containers (>=0.6.5 && <0.8), directory (>=1.3.6 && <1.4), ghc (>=9.4 && <9.11), time (>=1.11.1 && <1.13), transformers (>=0.5.6 && <0.7) [details]
License BSD-3-Clause
Copyright 2021 Aaron Allen
Author Aaron Allen
Category Utility, Development
Home page
Bug tracker
Uploaded by aaronallen8455 at 2024-05-20T20:42:00Z
Distributions NixOS:
Downloads 1869 total (56 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-05-20 [all 1 reports]

Readme for pinned-warnings-

[back to package description]

Pinned Warnings

The problem

When working in GHCi, it's easy to lose track of warnings from modules other than the one you are currently editing. Having to reload the project to catch any warnings you might have missed is painful.

The solution

This package has a GHC plugin that allows you to see all the current warnings from all modules in GHCi by calling a special showWarnings function.


You can start GHCi in your project with one of the following commands to enable the necessary plugin. Add pinned-warnings as a package dependency to avoid having to include the additional argument.

cabal update
cabal new-repl -b pinned-warnings --repl-options="-fplugin PinnedWarnings"

stack update
stack repl --package pinned-warnings --ghci-options "-fplugin PinnedWarnings"

Then you must add the ShowWarnings module to the GHCi context:

:m + ShowWarnings

Now all active warnings can be viewed by evaluating showWarnings.


You can define a custom GHCi command in your .ghci file that adds the ShowWarnings module and calls showWarnings:

:def sw (\_ -> pure ":m + ShowWarnings \n showWarnings")

With this you can simply use :sw to view warnings.

Fixing warnings

There is limited functionality for automatically fixing warnings. Currently only warnings due to redundant module import statements are corrected but there is room for improvement in this regard.

To use this functionality, have the ShowWarnings module added to your GHCi session then evaluate fixWarnings.

Known limitations

  • Warnings that aren't for a specific module are not captured.
  • GHC versions less than 8.10.x are not supported.
  • If you make changes to files and call showWarnings without reloading first, the messages may not be referencing the right code anymore.