question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Occasionally, applying hlint suggestions doesn't work as expected

See original GitHub issue

Since the latest beta (?) applying hlint suggestions doesn’t always work. There are some cases where it does work, and others where the suggestion is inserted without overriding existing code. Here’s a sample:

sample :: [Int] -> (Int -> Int) -> [String]
sample xs f = (show . f) <$> xs

IntelliJ offers me a quick fix saying:

Reudundant bracket, change to show . f <$> xs

when I apply the fix, I end up with the following:

sample xs f = show . f <$> xs <$> xs

So, it doesn’t override <$> xs but inserts it (similar to when I press Enter instead of Tab for completion).

My guess is that it is related to when there are a function composition operator and redundant brackets involved, but I’m not sure about that.

I’m on plugin version 1.0.0-beta78, IntellIJ IDEA 2020.2.1 RC (Ultimate Edition) Build #IU-202.6948.36 (I faced the issue with 2020.2 as well)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
L7R7commented, Jan 30, 2021

I totally missed the notifications on this issue, sorry for letting you wait! I just downloaded beta85 and tried it. I can tell that it definitely got better. The fixes for my first examples work now (the sample function ones). However, the last one is still a bit weird. For this one:

blabla = (\header -> (fst header) == "privateToken")

I get three suggestions (two redundant brackets and one redundant lambda). The fixes for brackets work, but when I apply the fix for the redundant lambda I get:

blheaderblheader header = (fst heheaderder) == "privheaderteToken"

Interestingly, the suggestion in the popup is weird already: image

I get the same behavior even when I apply the fixes for the brackets first

1reaction
rikvdkleijcommented, Sep 22, 2020

Investigated this issue and to solve this properly I have to change the integration with HLint. Will take some effort but it’s necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can HLint automatically do suggested edits?
Hlint directly calls the executable to apply the suggestions. Note that hlint doesn't apply transformations recursively, so additional ...
Read more >
hlint: Source code suggestions
HLint doesn't suggest optimisations, it suggests code improvements - the intention is to make the code simpler, rather than making the code ...
Read more >
Refactor program with HLint suggestions
The underlying Haskell parser library makes it hard to modify the code, then print it similarly to the original. Sometimes multiple transformations may...
Read more >
HLint: Haskell Source Code Suggestions - Morioh
HLint is a tool for suggesting possible improvements to Haskell code. These suggestions include ideas such as using alternative functions, simplifying code.
Read more >
Automatically Apply HLint Suggestions : r/haskell
Does that mean CPP mostly works (by which I mean is reproduced faithfully) with some edge cases that don't, or that it doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found