Currently when attrap responds to an error message like
• Variable not in scope:
(<+>)
:: m0 a0
-> Data.Text.Prettyprint.Doc.Internal.Doc ann0 -> m Constants
• Perhaps you meant one of these:
‘<>’ (imported from Prelude), ‘<*>’ (imported from Prelude),
‘<$>’ (imported from Prelude)
Perhaps you want to add ‘<+>’ to the import list in the import of
‘Data.Text.Prettyprint.Doc’
(/foo/bar/baz/Quux.hs:25:1-45).
it will do the following fix
import Data.Text.Prettyprint.Doc (Pretty(..),<+>)
But that's syntactically invalid! This PR makes the fix look like
The only tricky part here is to detect whether a name should be enclosed in parens, i.e. whether it's an operator. Since there's no dependency on haskell-mode which does have regexps to reliably ascertain that, I've settled on a less principled but more lightweight solution of treating anything that does not start with an uppercase, lowercase, _ or ' letter as an operator. Please let me know if you have any ideas on how this could be improved.
Currently when attrap responds to an error message like
it will do the following fix
But that's syntactically invalid! This PR makes the fix look like
The only tricky part here is to detect whether a name should be enclosed in parens, i.e. whether it's an operator. Since there's no dependency on haskell-mode which does have regexps to reliably ascertain that, I've settled on a less principled but more lightweight solution of treating anything that does not start with an uppercase, lowercase,
_
or'
letter as an operator. Please let me know if you have any ideas on how this could be improved.