Skip to content

Unable to process code using ImportQualifiedPost extension #104

@ncaq

Description

@ncaq

I've encountered an issue with sandwich when it attempts to process code that contains the ImportQualifiedPost syntax (e.g., import Data.List qualified as L). This causes parse errors because the underlying haskell-src-exts library doesn't support this GHC extension.

Workarounds

I've tried two approaches:

  1. Replacing with ghc-lib-parser: I attempted to swap out haskell-src-exts with ghc-lib-parser, but this proved to be quite challenging due to significant API differences and integration complexities.

  2. Patching haskell-src-exts: I've submitted a PR to add ImportQualifiedPost support to haskell-src-exts. The fix was relatively simple to implement (added the extension and modified the parser to support the syntax). While there's no guarantee it will be accepted given the maintenance status, it might provide a temporary solution.

feat: add support for ImportQualifiedPost extension by ncaq · Pull Request #477 · haskell-suite/haskell-src-exts

Discussion

I'd like to discuss options for moving forward:

  1. Should sandwich consider migrating away from haskell-src-exts to ghc-lib-parser in the long term?
  2. If my PR is accepted, would you consider updating the dependency in sandwich?
  3. Are there any other workarounds you'd recommend in the meantime?

For context, the reason I'm using ImportQualifiedPost syntax is that it's part of the formatting standards enforced by fourmolu in my project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions