u/SnakeStein

▲ 18 r/haskell

First time writing a GHC plugin (checking identity law) - Need some beginner advice

Hi everyone,
I am trying to write my very first Haskell compiler plugin. My goal is to build a tool that checks if the types in complete code base follows the identity law (parseJson . toJson = id).
Because I am a beginner to Haskell's compiler internals, the GHC documentation feels a bit overwhelming. I would love some advice to get started on the right foot:

  1. Where should I look? Haskell converts code into a few different forms before compiling it (Parsed code, Typechecked code, and Core code). I think parsed code should be the place where my plugin comes into picture. Let me know if I am getting something wrong.
  2. Good examples to read: Are there any simple, beginner-friendly compiler plugins on GitHub that I can look at just to understand how to set up the boilerplate code?
  3. Common mistakes: What are some common traps that beginners fall into when writing their first plugin?
    I am currently using GHC version 9.2.8
    Any beginner-friendly blogs, tutorials, or tips would be amazing. Thank you!
reddit.com
u/SnakeStein — 12 days ago