tfausak / splint

:newspaper_roll: HLint as a GHC source plugin.
https://hackage.haskell.org/package/splint
ISC License
31 stars 1 forks source link

Support older versions of GHC #2

Closed tfausak closed 4 years ago

tfausak commented 4 years ago

Is it possible to support versions of GHC other than 8.10? I'm not sure. It seems like HLint is tightly coupled to that version, but I haven't dug into it.

https://twitter.com/Iceland_jack/status/1264928483840491520

shayne-fletcher commented 4 years ago

HLint is coupled to ghc-8.10 in the sense that it operates on 8.10 parse trees. At build time, if HLint detects the build compiler is 8.10.*, it satisfies the definition of the parse tree types by linking that compiler's native GHC libraries (for the reasons of saving build time). If the build compiler is not an 8.10 (e.g. 8.8.3 or 8.6.5), it will instead link ghc-lib to satisfy those definitions.

shayne-fletcher commented 4 years ago

When using HLint as a library, if you can produce a compatible parse tree exogenously, then you can pass it through the HLint API. If you can't though, not all is lost - you can have HLint do it's own parse. This of course means that for example, you can with build compiler 8.6.5 link HLint with ghc-lib and if you allow it to do it's own parse, then it can do lint analysis. Not being familiar with the plugin concept I can't tell you if this information is helpful or not but I hope you can make sense of it!

tfausak commented 4 years ago

Thanks @shayne-fletcher! It sounds like the way forward is to do what hlint-source-plugin does. Or rather, also do that. When using GHC 8.10, everything should work the way it does now. But when using any other version (older or newer) HLint should re-parse the module itself and use that.

shayne-fletcher commented 4 years ago

Yes, check out hlint's stack.yaml and .cabal - do as it does with respect to ghc-lib and ghc-lib-parser-ex flags for linking, a little cpp in your plugin on ghc version and you should be all set.

shayne-fletcher commented 4 years ago

Alternatively, you could have hlint link ghc-lib unconditionally and allow it to always do it's parse. Might be simpler. Whatever works before the boss fires you! 😁