Skip to content

Commit aaf5736

Browse files
dylan-thinnesJaro Reinders
authored andcommitted
More stylish-haskell, more CPP fix
1 parent 342b9fb commit aaf5736

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

ghcide/src/Development/IDE/Core/HaskellErrorIndex.hs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
-- Retrieve the list of errors from the HaskellErrorIndex via its API
2-
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE CPP #-}
33

44
module Development.IDE.Core.HaskellErrorIndex where
55

66
import Control.Exception (tryJust)
7-
import Data.Aeson (FromJSON (..), (.:), withObject)
7+
import Data.Aeson (FromJSON (..), withObject,
8+
(.:))
89
import qualified Data.Map as M
910
import qualified Data.Text as T
1011
import Development.IDE.Types.Diagnostics
11-
import GHC.Driver.Errors.Types ( GhcMessage
12+
import GHC.Driver.Errors.Types (GhcMessage)
1213
#if MIN_VERSION_ghc(9,6,1)
13-
, DiagnosticCode, diagnosticCode
14+
import GHC.Types.Error (diagnosticCode)
1415
#endif
15-
)
16-
import Ide.Logger (Recorder, Pretty (..), WithPriority, logWith, Priority (..), vcat)
17-
import Language.LSP.Protocol.Types (Uri (..), CodeDescription (..))
18-
import Network.HTTP.Simple (HttpException, JSONException, getResponseBody, httpJSON)
16+
import Ide.Logger (Pretty (..), Priority (..),
17+
Recorder, WithPriority,
18+
logWith, vcat)
19+
import Language.LSP.Protocol.Types (CodeDescription (..),
20+
Uri (..))
21+
import Network.HTTP.Simple (HttpException,
22+
JSONException,
23+
getResponseBody, httpJSON)
1924

2025
data Log
2126
= LogHaskellErrorIndexInitialized
@@ -41,7 +46,7 @@ newtype HaskellErrorIndex = HaskellErrorIndex (M.Map T.Text HEIError)
4146
deriving (Show, Eq, Ord)
4247

4348
data HEIError = HEIError
44-
{ code :: T.Text
49+
{ code :: T.Text
4550
, route :: T.Text
4651
}
4752
deriving (Show, Eq, Ord)
@@ -60,8 +65,8 @@ instance FromJSON HaskellErrorIndex where
6065
parseJSON = fmap errorsToIndex <$> parseJSON
6166

6267
initHaskellErrorIndex :: Recorder (WithPriority Log) -> IO (Maybe HaskellErrorIndex)
63-
initHaskellErrorIndex recorder = do
6468
#if MIN_VERSION_ghc(9,6,1)
69+
initHaskellErrorIndex recorder = do
6570
res <- tryJust handleJSONError $ tryJust handleHttpError $ httpJSON "https://errors.haskell.org/api/errors.json"
6671
case res of
6772
Left jsonErr -> do
@@ -77,13 +82,13 @@ initHaskellErrorIndex recorder = do
7782
handleHttpError :: HttpException -> Maybe HttpException
7883
handleHttpError = Just
7984
#else
80-
pure Nothing
85+
initHaskellErrorIndex recorder = pure Nothing
8186
#endif
8287

8388
heiGetError :: HaskellErrorIndex -> GhcMessage -> Maybe HEIError
8489
heiGetError (HaskellErrorIndex index) msg
8590
#if MIN_VERSION_ghc(9,6,1)
86-
| Just code <- diagnosticCode (errMsgDiagnostic msg)
91+
| Just code <- diagnosticCode msg
8792
= showGhcCode code `M.lookup` index
8893
| otherwise
8994
= Nothing

0 commit comments

Comments
 (0)