ndmitchell / ndmitchell/hlint

Preprocessor confused by multi-line quasiquotes with hashes at line start

Open
#844 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
1.6k
Forks
210
PR merge metrics
No merged PRs in 30d

Description

Sometimes I like to generate strings by using multi-line quasiquote expressions + interpolation like this (using the interpolate package):

generatedStuff = [i|
Some static content:
#{generateStuff args}
|]

The fact that there's a # at the beginning of a line seems to confuse hlint, resulting in warnings like Warning: unknown directive #{generateStuff.

This seems related to #501, but it's a normal .hs file, not something unusual like literate Haskell. It seems like somewhere in the parsing process it's not understanding the quasiquote the way GHC does.

I confirmed that passing --cpp-simple makes the warnings go away, as that issue suggested.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning with the Haskell quasiquote example, comparing normal processing with --cpp-simple. Trace HLint's preprocessing or parsing of .hs files and quasiquotes; done means the interpolation line no longer produces an unknown-directive warning without requiring --cpp-simple.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.