diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 3a6f315..a383d2c 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -868,6 +868,8 @@ setGHC ver sghc = do -- create symlink for share dir when (isNothing . _tvTarget $ ver) $ lift $ symlinkShareDir ghcdir verS + when (sghc == SetGHCOnly) $ lift warnAboutHlsCompatibility + pure ver where @@ -978,6 +980,8 @@ setHLS ver = do lift $ createLink destL wrapper + lift warnAboutHlsCompatibility + pure () @@ -1010,6 +1014,29 @@ setStack ver = do pure () +-- | Warn if the installed and set HLS is not compatible with the installed and +-- set GHC version. +warnAboutHlsCompatibility :: ( MonadReader env m + , HasDirs env + , HasLog env + , MonadThrow m + , MonadCatch m + , MonadIO m + ) + => m () +warnAboutHlsCompatibility = do + supportedGHC <- hlsGHCVersions + currentGHC <- fmap _tvVersion <$> ghcSet Nothing + currentHLS <- hlsSet + + case (currentGHC, currentHLS) of + (Just gv, Just hv) | gv `notElem` supportedGHC -> do + logWarn $ "GHC " <> T.pack (prettyShow gv) <> " is not compatible with " + <> "Haskell Language Server " <> T.pack (prettyShow hv) <> "." + logWarn "Haskell IDE support may not work until this is fixed." + logWarn $ "Install a different HLS version, or run `ghcup list` to see " + <> "supported GHC versions." + _ -> return () ------------------ --[ List tools ]--