Share useful GHC plugins

I know of a few ghc plugins:
norecursion: Allows for making recursion useful, avoiding recursion bugs.
ghc-typelits-normalize Allows for making Type level
typelet: Allows type level let
monadic-bang: Allows for idris ! syntax.
There is also the polysemy and or-constraint ones.
I just saw monadic-bang and it seemed cool, and I began to wonder what other cool plugins there are that could make the haskell experience better?

5 Likes

opentelemetry-plugin to hook up OpenTelemetry to GHC and measure various thing about building Haskell programs.

I’ve never used it though!

5 Likes

liquid haskell? Implementing a GHC Plugin for Liquid Haskell - Well-Typed: The Haskell Consultants

7 Likes

I use monadic-bang all the time and it’s great. I still think it should be a native extension, because there are a few issues with plugins that add syntax.

  • When there’s a syntax error anywhere in the file, there will be a syntax error for each !expression as well
  • There’s no way to integrate with code formatters — Ormolu has no idea what’s going on and fails at the first !expression
  • It would be nice to allow a low-precedence form <- expression instead of (or in addition to) the high-precedence !expression, because in practice, having ! be high-precedence doesn’t allow me to drop parentheses very often, and I’d rather write if <- f x then … instead of if !(f x) then …, and f (<- g x) <- h y instead of f !(g x) !(h y)
2 Likes

Not exactly useful at the moment, but I always wanted to continue my assert-explainer plugin: GitHub - ocharles/assert-explainer: Py.test style assertions in Haskell

5 Likes

The final work i did for the GSoC that just ended was a GHC plugin that serializes and deserializes cmm . Cmm being the GHC code generation IR. It gets translated from a higher level IR and then translated directly to machine code, to llvm or to wasm

4 Likes

One of my goals in Skeletest is to provide helpful error messages. If you like pytest, you might also like the Fixtures mechanism.

5 Likes

On a similar topic, I have a simple TH function that lets you match on data structures without having to state all sub-parts of the structure. In the example below I’ve omitted various fields (like source location information which is verbose), and used _ where ArrayExpression was important, but its content wasn’t. It’s like writing a case but without having to write the RHS or wildcard case. My hope for a follow up would be having it report the diff rather than a simple boolean. I think if you have an instance of Lift, you could diff on the AST.

Your example could be e.g. shouldBeLift xs [| [_,_,_] |] which is occasionally nicer, depending on the task. But it’s only a subset of the things your plugin can help with, which is much broader.

1 Like