Skip to content

Commit 7edbad5

Browse files
committed
Ghc 8.8.1 support
1 parent c4c04ce commit 7edbad5

File tree

9 files changed

+60
-36
lines changed

9 files changed

+60
-36
lines changed

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@
1818

1919
[submodule "submodules/ghc-mod"]
2020
path = submodules/ghc-mod
21-
url = https://github.com/fendor/ghc-mod.git
21+
url = https://github.com/fendor/ghc-mod.git
22+
[submodule "submodules/apply-refact"]
23+
path = submodules/apply-refact
24+
url = https://github.com/mpickering/apply-refact.git

haskell-ide-engine.cabal

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build-type: Simple
1414
cabal-version: >=2.0
1515

1616
flag pedantic
17-
Description: Enable -Werror
17+
Description: Enable -Werror -Wwarn=unused-imports
1818
Default: False
1919

2020
library
@@ -103,7 +103,7 @@ library
103103

104104
ghc-options: -Wall -Wredundant-constraints
105105
if flag(pedantic)
106-
ghc-options: -Werror
106+
ghc-options: -Werror -Wwarn=unused-imports
107107
default-language: Haskell2010
108108

109109
executable hie
@@ -122,7 +122,7 @@ executable hie
122122
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
123123
-with-rtsopts=-T
124124
if flag(pedantic)
125-
ghc-options: -Werror
125+
ghc-options: -Werror -Wwarn=unused-imports
126126
default-language: Haskell2010
127127

128128

@@ -143,7 +143,7 @@ executable hie-wrapper
143143
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
144144
-with-rtsopts=-T
145145
if flag(pedantic)
146-
ghc-options: -Werror
146+
ghc-options: -Werror -Wwarn=unused-imports
147147
default-language: Haskell2010
148148

149149
library hie-test-utils
@@ -169,7 +169,7 @@ library hie-test-utils
169169
, yaml
170170
ghc-options: -Wall -Wredundant-constraints
171171
if flag(pedantic)
172-
ghc-options: -Werror
172+
ghc-options: -Werror -Wwarn=unused-imports
173173
default-language: Haskell2010
174174

175175
test-suite unit-test
@@ -213,7 +213,7 @@ test-suite unit-test
213213

214214
ghc-options: -Wall -Wredundant-constraints
215215
if flag(pedantic)
216-
ghc-options: -Werror
216+
ghc-options: -Werror -Wwarn=unused-imports
217217
default-language: Haskell2010
218218

219219
test-suite dispatcher-test
@@ -237,7 +237,7 @@ test-suite dispatcher-test
237237

238238
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
239239
if flag(pedantic)
240-
ghc-options: -Werror
240+
ghc-options: -Werror -Wwarn=unused-imports
241241
default-language: Haskell2010
242242
build-tool-depends: hspec-discover:hspec-discover
243243

@@ -257,7 +257,7 @@ test-suite plugin-dispatcher-test
257257

258258
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
259259
if flag(pedantic)
260-
ghc-options: -Werror
260+
ghc-options: -Werror -Wwarn=unused-imports
261261
default-language: Haskell2010
262262

263263
test-suite func-test
@@ -302,7 +302,7 @@ test-suite func-test
302302
, containers
303303
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
304304
if flag(pedantic)
305-
ghc-options: -Werror
305+
ghc-options: -Werror -Wwarn=unused-imports
306306
default-language: Haskell2010
307307
build-tool-depends: hspec-discover:hspec-discover
308308
, haskell-ide-engine:hie
@@ -321,7 +321,7 @@ test-suite wrapper-test
321321
, hie-plugin-api
322322
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wredundant-constraints
323323
if flag(pedantic)
324-
ghc-options: -Werror
324+
ghc-options: -Werror -Wwarn=unused-imports
325325
default-language: Haskell2010
326326

327327

install/shake.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Used to provide a different environment for the shake build script
2-
resolver: lts-14.11 # GHC 8.6.5
2+
resolver: lts-14.17 # GHC 8.6.5
33
packages:
44
- .
55

src/Haskell/Ide/Engine/Plugin/Haddock.hs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE NamedFieldPuns #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE RankNTypes #-}
@@ -106,7 +107,11 @@ getDocsForName df name = do
106107
case mf of
107108
Nothing -> return Nothing
108109
Just f -> do
110+
#if __GLASGOW_HASKELL__ >= 808
111+
ehi <- readInterfaceFile nameCacheFromIdeM f True
112+
#else
109113
ehi <- readInterfaceFile nameCacheFromIdeM f
114+
#endif
110115
case ehi of
111116
Left message -> do
112117
debugm $ "Haddock docs couldn't be loaded as readInterfaceFile failed with: " ++ message
@@ -151,8 +156,15 @@ prettyprintType n t = T.unlines
151156
, "```\n"
152157
]
153158

159+
unwrap :: Foldable w => w a -> a
160+
unwrap = foldl1 (const id)
161+
154162
renderDocs :: MDoc Name -> T.Text
163+
#if __GLASGOW_HASKELL__ >= 808
164+
renderDocs = markup renderMarkDown . _doc . fmap unwrap
165+
#else
155166
renderDocs = markup renderMarkDown . _doc
167+
#endif
156168

157169
renderMarkDown :: DocMarkup Name T.Text
158170
renderMarkDown =
@@ -161,7 +173,11 @@ renderMarkDown =
161173
, markupParagraph = (<> "\n\n")
162174
, markupAppend = mappend
163175
, markupIdentifier = surround "`" . T.pack . getOccString
176+
#if __GLASGOW_HASKELL__ >= 808
177+
, markupIdentifierUnchecked = T.pack . occNameString . snd . unwrap
178+
#else
164179
, markupIdentifierUnchecked = T.pack . occNameString . snd
180+
#endif
165181
, markupModule = surround "**" . T.pack
166182
, markupWarning = surround "*"
167183
, markupEmphasis = surround "*"
@@ -173,9 +189,16 @@ renderMarkDown =
173189
, markupDefList = T.unlines . map (\(a, b) -> a <> " :: " <> b)
174190
, markupCodeBlock = \x -> "\n```haskell\n" <> removeInner x <> "\n```\n"
175191
, markupHyperlink = \h ->
176-
T.pack $ maybe
192+
#if __GLASGOW_HASKELL__ >= 808
193+
let url = T.pack $ hyperlinkUrl h
194+
in maybe
195+
url
196+
(\l -> "["<>l<>"]("<>url<>")")
197+
#else
198+
T.pack $ maybe
177199
(hyperlinkUrl h)
178200
(\l -> "["<>l<>"]("<>hyperlinkUrl h<>")")
201+
#endif
179202
(hyperlinkLabel h)
180203
, markupAName = T.pack
181204
, markupPic = const ""

src/Haskell/Ide/Engine/Plugin/Package.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import qualified Data.ByteString as B
1919
import Data.Foldable
2020
import Data.List
2121
import qualified Data.HashMap.Strict as HM
22+
import qualified Data.Set as S
2223
import qualified Data.Text as T
2324
import qualified Data.Text.Encoding as T
2425
import Data.Maybe
@@ -301,7 +302,11 @@ editCabalPackage file modulePath pkgName fileMap = do
301302
-- Add it to the bottom of the dependencies list
302303
-- TODO: we could sort the depencies and then insert it,
303304
-- or insert it in order iff the list is already sorted.
305+
#if __GLASGOW_HASKELL__ >= 808
306+
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion S.empty]
307+
#else
304308
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion]
309+
#endif
305310

306311
-- | Provide a code action to add a package to the local package.yaml or cabal file.
307312
-- Reads from diagnostics the unknown import module path and searches for it on Hoogle.

src/Haskell/Ide/Engine/Support/HieExtras.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveGeneric #-}
23
{-# LANGUAGE NamedFieldPuns #-}
34
{-# LANGUAGE ScopedTypeVariables #-}
@@ -336,7 +337,11 @@ gotoModule rfm mn = do
336337
flushFinderCaches env
337338
findImportedModule env mn Nothing
338339
case fr of
340+
#if __GLASGOW_HASKELL__ < 808
339341
Found (ModLocation (Just src) _ _) _ -> do
342+
#else
343+
Found (ModLocation (Just src) _ _ _) _ -> do
344+
#endif
340345
fp <- reverseMapFile rfm src
341346

342347
let r = Range (Position 0 0) (Position 0 0)

stack-8.6.5.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-14.16
1+
resolver: lts-14.17
22
packages:
33
- .
44
- hie-plugin-api

stack.yaml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: nightly-2019-09-21 # Last GHC 8.6.5
1+
resolver: nightly-2019-12-18
22
packages:
33
- .
44
- hie-plugin-api
@@ -7,31 +7,18 @@ extra-deps:
77
# - ./submodules/HaRe
88
- ./submodules/cabal-helper
99
- ./submodules/ghc-mod/ghc-project-types
10-
11-
- deque-0.4.3
12-
- ansi-terminal-0.8.2
10+
- ./submodules/apply-refact
11+
- hie-bios-0.3.2
1312
- bytestring-trie-0.2.5.0
14-
- ansi-wl-pprint-0.6.8.2
15-
- brittany-0.12.1.0
16-
- cabal-plan-0.5.0.0
1713
- constrained-dynamic-0.1.0.0
14+
- fclabels-2.0.3.3
1815
- floskell-0.10.2
19-
- ghc-lib-parser-8.8.1
20-
- haddock-api-2.22.0
21-
- haskell-lsp-0.19.0.0
22-
- haskell-lsp-types-0.19.0.0
23-
- hie-bios-0.3.2
24-
- hlint-2.2.4
16+
- fold-debounce-0.2.0.9
17+
- haddock-api-2.23.0
18+
- haddock-library-1.8.0
19+
- hoogle-5.0.17.13
2520
- hsimport-0.11.0
26-
- lsp-test-0.9.0.0
27-
- monad-dijkstra-0.1.1.2@rev:1
28-
- syz-0.2.0.0
29-
- temporary-1.2.1.1
30-
- clock-0.7.2
31-
- ghc-exactprint-0.6.2 # for HaRe
32-
- extra-1.6.18
33-
- unix-compat-0.5.2
34-
- yaml-0.11.1.2
21+
- monad-dijkstra-0.1.1.2
3522

3623
flags:
3724
haskell-ide-engine:

submodules/apply-refact

Submodule apply-refact added at 1acf7eb

0 commit comments

Comments
 (0)