Skip to content

Instantly share code, notes, and snippets.

@Aster89
Last active September 4, 2026 08:28
Show Gist options
  • Select an option

  • Save Aster89/69a57c364ec2d0cc89f474cc3d194371 to your computer and use it in GitHub Desktop.

Select an option

Save Aster89/69a57c364ec2d0cc89f474cc3d194371 to your computer and use it in GitHub Desktop.
Google Summer of Code 2026 - Project Summary

Google Summer of Code 2026 - Project Summary


Project Goals

This PR is for (re-¹)introducing the so called case-split plugin, as requested in haskell/haskell-language-server#5013.

The main goals were:

  • create a plugin that uses existing APIs, e.g. ghc-exactprint's, in order to correctly insert missing patterns to case/\case expressions with a non-exhaustive list of patterns, i.e. a plugin that can turn, as a simple example, this
    data X = A
           | B
           | C Int
           | D Int Int
           | E Int Int Int Int
           | F
    
    foo :: X -> Int
    foo x = case x of
              A -> 3;
                    B -> 4;
                  C _ -> 5
    into this
    data X = -- same as above
    
    foo :: X -> Int
    foo x = case x of
              A -> 3;
                    B -> 4;
                  C _ -> 5
              D _ _ -> _
              E {} -> _
              F -> _
  • write code in a way that it would easily be reused for scenarii other than incomplete case expression "proper" use-cases (see § Future work below)
  • support "ordinary" ADTs;
  • support GATDs.

Contributions

My work has consisted mainly of:

  • implementing the plugin by incrementally focusing on several use-cases from less to more complex,
  • contextually writing tests for guarding such use-cases as I enabled them,
  • addressing feedback received by my mentors' via their reviews and via live discussions in our weekly meetings.

Besides, some minor contributions were also carried out:

Challenges

  1. Becoming comfortable in inspecting an AST itself (specifically a ParsedSource, i.e. a Located (HsModule GhcPs)), was a challenge, but way easier than it would have been, once @fendor told me about showAst.

  2. By far, the greatest challenge was - or actually is, because I'm working on the stretch goals below - understanding ghc-exactprint APIs and how they relate to the AST.

  3. The simple fact of getting used to names of relevant types, and remembering them took a lot of commitment, that initially translated in me going back and forth from my IDE to Hoogle multiple times per coding session, even.

Future work / stretch goals


¹ Earlier attempts

Earlier attempts at introducing such a plugin, documented in haskell/haskell-language-server#3525, were productive in outlining the challenges and in exploring plans of attack and possible solutions, but the resulting product ultimately did not stand the test of time, due to its poor maintainability.

A few years later, HLS, ghc-exactprint, GHC and the whole Haskell ecosystem have piled up quite a few more releases worth of experience on their back, which warrants another attempt at addressing this task might be fruitful, hence my work aims at addressing such long-standing lack of support for a feature that seems so simple from the user's perspective, which is my own as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment