Commit 180e42ba authored by Vaibhav Sagar's avatar Vaibhav Sagar

ihaskell: add `use-hlint` flag

parent 42a78084
...@@ -49,6 +49,11 @@ data-files: ...@@ -49,6 +49,11 @@ data-files:
jupyterlab-ihaskell/labextension/static/*.js jupyterlab-ihaskell/labextension/static/*.js
jupyterlab-ihaskell/labextension/static/*.json jupyterlab-ihaskell/labextension/static/*.json
flag use-hlint
description: Include HLint support
default: True
manual: True
library library
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010
...@@ -72,7 +77,6 @@ library ...@@ -72,7 +77,6 @@ library
ghc-parser >=0.2.1, ghc-parser >=0.2.1,
ghc-paths >=0.1, ghc-paths >=0.1,
haskeline -any, haskeline -any,
hlint >=1.9,
http-client >= 0.4, http-client >= 0.4,
http-client-tls >= 0.2, http-client-tls >= 0.2,
mtl >=2.1, mtl >=2.1,
...@@ -93,10 +97,6 @@ library ...@@ -93,10 +97,6 @@ library
ipython-kernel >=0.10.2.0, ipython-kernel >=0.10.2.0,
ghc-boot >=8.0 && <9.1 ghc-boot >=8.0 && <9.1
if impl (ghc < 8.10)
build-depends:
haskell-src-exts >=1.18
exposed-modules: IHaskell.Display exposed-modules: IHaskell.Display
IHaskell.Convert IHaskell.Convert
IHaskell.Convert.Args IHaskell.Convert.Args
...@@ -106,7 +106,6 @@ library ...@@ -106,7 +106,6 @@ library
IHaskell.Eval.Inspect IHaskell.Eval.Inspect
IHaskell.Eval.Evaluate IHaskell.Eval.Evaluate
IHaskell.Eval.Info IHaskell.Eval.Info
IHaskell.Eval.Lint
IHaskell.Eval.Parser IHaskell.Eval.Parser
IHaskell.Eval.Hoogle IHaskell.Eval.Hoogle
IHaskell.Eval.ParseShell IHaskell.Eval.ParseShell
...@@ -124,6 +123,14 @@ library ...@@ -124,6 +123,14 @@ library
other-modules: other-modules:
StringUtils StringUtils
if flag(use-hlint)
exposed-modules: IHaskell.Eval.Lint
build-depends: hlint >=1.9
cpp-options: -DUSE_HLINT
if flag(use-hlint) && impl (ghc < 8.10)
build-depends: haskell-src-exts >=1.18
executable ihaskell executable ihaskell
-- .hs or .lhs file containing the Main module. -- .hs or .lhs file containing the Main module.
main-is: Main.hs main-is: Main.hs
......
...@@ -68,13 +68,16 @@ import GHC hiding (Stmt, TypeSig) ...@@ -68,13 +68,16 @@ import GHC hiding (Stmt, TypeSig)
import IHaskell.Types import IHaskell.Types
import IHaskell.IPython import IHaskell.IPython
import IHaskell.Eval.Parser import IHaskell.Eval.Parser
import IHaskell.Eval.Lint
import IHaskell.Display import IHaskell.Display
import qualified IHaskell.Eval.Hoogle as Hoogle import qualified IHaskell.Eval.Hoogle as Hoogle
import IHaskell.Eval.Util import IHaskell.Eval.Util
import IHaskell.BrokenPackages import IHaskell.BrokenPackages
import StringUtils (replace, split, strip, rstrip) import StringUtils (replace, split, strip, rstrip)
#ifdef USE_HLINT
import IHaskell.Eval.Lint
#endif
#if MIN_VERSION_ghc(9,0,0) #if MIN_VERSION_ghc(9,0,0)
import GHC.Data.FastString import GHC.Data.FastString
#elif MIN_VERSION_ghc(8,2,0) #elif MIN_VERSION_ghc(8,2,0)
...@@ -351,10 +354,13 @@ evaluate kernelState code output widgetHandler = do ...@@ -351,10 +354,13 @@ evaluate kernelState code output widgetHandler = do
updated <- case errs of updated <- case errs of
-- Only run things if there are no parse errors. -- Only run things if there are no parse errors.
[] -> do [] -> do
#ifdef USE_HLINT
when (getLintStatus kernelState /= LintOff) $ liftIO $ do when (getLintStatus kernelState /= LintOff) $ liftIO $ do
lintSuggestions <- lint code cmds lintSuggestions <- lint code cmds
unless (noResults lintSuggestions) $ unless (noResults lintSuggestions) $
output (FinalResult lintSuggestions [] []) Success output (FinalResult lintSuggestions [] []) Success
#endif
runUntilFailure kernelState (map unloc cmds ++ [storeItCommand execCount]) runUntilFailure kernelState (map unloc cmds ++ [storeItCommand execCount])
-- Print all parse errors. -- Print all parse errors.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment