Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit f4600b7

Browse files
authored
Merge pull request #1482 from Avi-D-coder/hie-bios
GHC 8.8 support
2 parents 08e2bb0 + fbeb428 commit f4600b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+262
-94
lines changed

.azure/linux-stack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
matrix:
88
stack-def:
99
YAML_FILE: stack.yaml
10+
stack-8.8.1:
11+
YAML_FILE: stack-8.8.1.yaml
1012
stack-8.6.5:
1113
YAML_FILE: stack-8.6.5.yaml
1214
stack-8.6.4:

.azure/macos-stack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
matrix:
88
stack-def:
99
YAML_FILE: stack.yaml
10+
stack-8.8.1:
11+
YAML_FILE: stack-8.8.1.yaml
1012
stack-8.6.5:
1113
YAML_FILE: stack-8.6.5.yaml
1214
stack-8.6.4:

.azure/windows-stack.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ jobs:
55
vmImage: windows-2019
66
strategy:
77
matrix:
8-
stack-def:
9-
YAML_FILE: stack.yaml
8+
# We can't use stack.yaml while it uses ghc-8.8.1
9+
# stack-def:
10+
# YAML_FILE: stack.yaml
1011
stack-8.6.5:
1112
YAML_FILE: stack-8.6.5.yaml
1213
stack-8.6.4:

.circleci/config.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
cabal:
150150
working_directory: ~/build
151151
docker:
152-
- image: quay.io/haskell_works/ghc-8.6.5
152+
- image: haskell:8.8.1
153153
steps:
154154
- checkout
155155
- run:
@@ -161,18 +161,15 @@ jobs:
161161
- restore-cache:
162162
keys:
163163
- cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
164-
- run:
165-
name: Cabal version
166-
command: cabal --version
167164
- run:
168165
name: Update
169-
command: cabal new-update
166+
command: cabal update
170167
- run:
171168
name: Configure
172-
command: cabal new-configure --enable-tests
169+
command: cabal configure --enable-tests
173170
- run:
174171
name: Build
175-
command: cabal new-build -j1 # need j1, else ghc-lib-parser triggers OOM
172+
command: cabal build -j1 # need j1, else ghc-lib-parser triggers OOM
176173
no_output_timeout: 30m
177174
- save_cache:
178175
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}

app/MainHie.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-# LANGUAGE RankNTypes #-}
34
module Main where
45

56
import qualified Control.Exception as E
67
import Control.Monad
8+
#if __GLASGOW_HASKELL__ < 808
79
import Data.Monoid ((<>))
10+
#endif
811
import Data.Version (showVersion)
912
import qualified Data.Text as T
1013
import qualified Data.Text.IO as T

hie-plugin-api/Haskell/Ide/Engine/Ghc.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Control.Monad ( when )
2323
import Data.IORef
2424
import qualified Data.Map.Strict as Map
2525
-- import qualified Data.IntMap.Strict as IM
26-
import Data.Semigroup ((<>), Semigroup)
2726
import qualified Data.Set as Set
2827
import qualified Data.Text as T
2928
import qualified Data.Aeson
@@ -37,7 +36,12 @@ import Haskell.Ide.Engine.PluginUtils
3736
import DynFlags
3837
import GHC
3938
import qualified HscTypes
39+
40+
#if __GLASGOW_HASKELL__ < 808
41+
import Data.Semigroup ((<>), Semigroup)
4042
import Outputable (renderWithStyle)
43+
#endif
44+
4145
import Language.Haskell.LSP.Types ( NormalizedUri(..), toNormalizedUri )
4246

4347
import Haskell.Ide.Engine.GhcUtils

hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveGeneric #-}
23
{-# LANGUAGE DeriveFunctor #-}
34
{-# LANGUAGE DeriveAnyClass #-}
@@ -111,13 +112,17 @@ import qualified Data.List as List
111112
import Data.Dynamic ( Dynamic )
112113
import qualified Data.Map as Map
113114
import Data.Maybe
114-
import Data.Monoid ( (<>) )
115+
115116
import qualified Data.Set as S
116117
import Data.String
117118
import qualified Data.Text as T
118-
import Data.Typeable ( TypeRep
119-
, Typeable
120-
)
119+
import Data.Typeable ( TypeRep )
120+
121+
#if __GLASGOW_HASKELL__ < 808
122+
import Data.Monoid ( (<>) )
123+
import Data.Typeable ( Typeable )
124+
#endif
125+
121126
import System.Directory
122127
import GhcMonad
123128
import GHC.Generics

install/src/Env.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ getHieVersions = do
104104
& mapMaybe
105105
(T.stripPrefix stackYamlPrefix >=> T.stripSuffix stackYamlSuffix)
106106
& map T.unpack
107-
-- the following line excludes `8.6.3` on windows systems
108-
& filter (\p -> not isWindowsSystem || p /= "8.6.3")
107+
-- the following line excludes `8.6.3` and `8.8.1` on windows systems
108+
& filter (\p -> not (isWindowsSystem && p `elem` ["8.6.3","8.8.1"]))
109109
& sort
110110
return hieVersions
111111

src/Haskell/Ide/Engine/Completions.hs

Lines changed: 3 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 OverloadedStrings #-}
@@ -23,7 +24,9 @@ import qualified Data.List as List
2324
import qualified Data.Text as T
2425
import qualified Data.Map as Map
2526
import Data.Maybe
27+
#if __GLASGOW_HASKELL__ < 808
2628
import Data.Semigroup (Semigroup(..))
29+
#endif
2730
import Data.Typeable
2831
import GHC.Generics ( Generic )
2932

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveAnyClass #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE DuplicateRecordFields #-}
@@ -19,7 +20,11 @@ import Control.Monad.IO.Class
1920
import Control.Monad.Trans.Except
2021
import Data.Aeson hiding (Error)
2122
import Data.Maybe
23+
24+
#if __GLASGOW_HASKELL__ < 808
2225
import Data.Monoid ((<>))
26+
#endif
27+
2328
import qualified Data.Text as T
2429
import GHC.Generics
2530
import Haskell.Ide.Engine.MonadFunctions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import Haskell.Ide.Engine.PluginUtils
1515
import Language.Haskell.Brittany
1616
import qualified Language.Haskell.LSP.Types as J
1717
import qualified Language.Haskell.LSP.Types.Lens as J
18-
import System.FilePath (FilePath, takeDirectory)
18+
19+
import System.FilePath
1920
import Data.Maybe (maybeToList)
2021

2122
brittanyDescriptor :: PluginId -> PluginDescriptor

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import Data.Function
1414
import qualified Data.HashMap.Strict as HM
1515
import Data.List
1616
import Data.Maybe
17+
#if __GLASGOW_HASKELL__ < 808
1718
import Data.Monoid ((<>))
19+
#endif
1820
import qualified Data.Text as T
1921
import Name
2022
import GHC.Generics

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ module Haskell.Ide.Engine.Plugin.GhcMod
2626
) where
2727

2828
import Data.Aeson
29+
#if __GLASGOW_HASKELL__ < 808
2930
import Data.Monoid ((<>))
31+
#endif
3032
import GHC.Generics
3133
import qualified Haskell.Ide.Engine.Ghc as HIE
3234
import Haskell.Ide.Engine.MonadTypes

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 OverloadedStrings #-}
23
{-# LANGUAGE RankNTypes #-}
34
{-# LANGUAGE ScopedTypeVariables #-}
@@ -107,7 +108,11 @@ getDocsForName df name = do
107108
case mf of
108109
Nothing -> return Nothing
109110
Just f -> do
111+
#if __GLASGOW_HASKELL__ >= 808
112+
ehi <- readInterfaceFile nameCacheFromIdeM f True
113+
#else
110114
ehi <- readInterfaceFile nameCacheFromIdeM f
115+
#endif
111116
case ehi of
112117
Left message -> do
113118
debugm $ "Haddock docs couldn't be loaded as readInterfaceFile failed with: " ++ message
@@ -152,8 +157,15 @@ prettyprintType n t = T.unlines
152157
, "```\n"
153158
]
154159

160+
unwrap :: Foldable w => w a -> a
161+
unwrap = foldl1 (const id)
162+
155163
renderDocs :: MDoc Name -> T.Text
164+
#if __GLASGOW_HASKELL__ >= 808
165+
renderDocs = markup renderMarkDown . _doc . fmap unwrap
166+
#else
156167
renderDocs = markup renderMarkDown . _doc
168+
#endif
157169

158170
renderMarkDown :: DocMarkup Name T.Text
159171
renderMarkDown =
@@ -162,7 +174,11 @@ renderMarkDown =
162174
, markupParagraph = (<> "\n\n")
163175
, markupAppend = mappend
164176
, markupIdentifier = surround "`" . T.pack . getOccString
177+
#if __GLASGOW_HASKELL__ >= 808
178+
, markupIdentifierUnchecked = T.pack . occNameString . snd . unwrap
179+
#else
165180
, markupIdentifierUnchecked = T.pack . occNameString . snd
181+
#endif
166182
, markupModule = surround "**" . T.pack
167183
, markupWarning = surround "*"
168184
, markupEmphasis = surround "*"
@@ -174,9 +190,16 @@ renderMarkDown =
174190
, markupDefList = T.unlines . map (\(a, b) -> a <> " :: " <> b)
175191
, markupCodeBlock = \x -> "\n```haskell\n" <> removeInner x <> "\n```\n"
176192
, markupHyperlink = \h ->
177-
T.pack $ maybe
193+
#if __GLASGOW_HASKELL__ >= 808
194+
let url = T.pack $ hyperlinkUrl h
195+
in maybe
196+
url
197+
(\l -> "["<>l<>"]("<>url<>")")
198+
#else
199+
T.pack $ maybe
178200
(hyperlinkUrl h)
179201
(\l -> "["<>l<>"]("<>hyperlinkUrl h<>")")
202+
#endif
180203
(hyperlinkLabel h)
181204
, markupAName = T.pack
182205
, markupPic = const ""

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE DeriveAnyClass #-}
@@ -13,7 +14,9 @@ import Control.Monad
1314
import Data.Aeson
1415
import Data.Foldable
1516
import Data.Maybe
17+
#if __GLASGOW_HASKELL__ < 808
1618
import Data.Monoid ( (<>) )
19+
#endif
1720
import qualified Data.Text as T
1821
import qualified Data.Text.IO as T
1922
import qualified GHC.Generics as Generics

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import qualified Data.HashMap.Strict as HM
2525
import qualified Data.Text as T
2626
import qualified Data.Text.Encoding as T
2727
import Data.Maybe
28+
#if __GLASGOW_HASKELL__ < 808
2829
import Data.Monoid ((<>))
30+
#else
31+
import qualified Data.Set as S
32+
#endif
2933
#if MIN_VERSION_Cabal(2,2,0)
3034
import Distribution.PackageDescription.Parsec
3135
import Distribution.Types.VersionRange
@@ -297,7 +301,11 @@ editCabalPackage file modulePath pkgName fileMap = do
297301
-- Add it to the bottom of the dependencies list
298302
-- TODO: we could sort the depencies and then insert it,
299303
-- or insert it in order iff the list is already sorted.
304+
#if __GLASGOW_HASKELL__ >= 808
305+
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion S.empty]
306+
#else
300307
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion]
308+
#endif
301309

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveAnyClass #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE OverloadedStrings #-}
@@ -8,7 +9,9 @@ module Haskell.Ide.Engine.Plugin.Pragmas where
89
import Control.Lens
910
import Data.Aeson
1011
import qualified Data.HashMap.Strict as H
12+
#if __GLASGOW_HASKELL__ < 808
1113
import Data.Monoid ((<>))
14+
#endif
1215
import qualified Data.Text as T
1316
import qualified GHC.Generics as Generics
1417
import Haskell.Ide.Engine.MonadTypes hiding (_range)

src/Haskell/Ide/Engine/Scheduler.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE FlexibleContexts #-}
23
{-# LANGUAGE MultiParamTypeClasses #-}
34
{-# LANGUAGE ExistentialQuantification #-}
@@ -25,9 +26,11 @@ where
2526
import Control.Concurrent.Async
2627
import GHC.Conc
2728
import qualified Control.Concurrent.STM as STM
28-
import Control.Monad.IO.Class ( liftIO
29-
, MonadIO
30-
)
29+
import Control.Monad.IO.Class ( MonadIO )
30+
#if __GLASGOW_HASKELL__ < 808
31+
import Control.Monad.IO.Class ( liftIO )
32+
#endif
33+
3134
import Control.Monad.Reader.Class ( ask
3235
, MonadReader
3336
)

src/Haskell/Ide/Engine/Server.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DuplicateRecordFields #-}
23
{-# LANGUAGE GADTs #-}
34
{-# LANGUAGE RankNTypes #-}
@@ -32,7 +33,10 @@ import Data.Default
3233
import Data.Foldable
3334
import qualified Data.Map as Map
3435
import Data.Maybe
35-
import Data.Semigroup (Semigroup(..), Option(..), option)
36+
import Data.Semigroup (Option(..), option)
37+
#if __GLASGOW_HASKELL__ < 808
38+
import Data.Semigroup (Semigroup(..), )
39+
#endif
3640
import qualified Data.Set as S
3741
import qualified Data.SortedList as SL
3842
import qualified Data.Text as T

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveGeneric #-}
23
{-# LANGUAGE NamedFieldPuns #-}
34
{-# LANGUAGE ScopedTypeVariables #-}
@@ -25,7 +26,11 @@ module Haskell.Ide.Engine.Support.HieExtras
2526
, getFormattingPlugin
2627
) where
2728

29+
#if __GLASGOW_HASKELL__ < 808
2830
import Data.Semigroup (Semigroup(..))
31+
import Var
32+
#endif
33+
2934
import ConLike
3035
import Control.Monad.Reader
3136
import Control.Monad.Except
@@ -62,7 +67,6 @@ import Packages
6267
import SrcLoc
6368
import TcEnv
6469
import Type
65-
import Var
6670
import Module hiding (getModule)
6771

6872
-- ---------------------------------------------------------------------
@@ -336,7 +340,11 @@ gotoModule rfm mn = do
336340
flushFinderCaches env
337341
findImportedModule env mn Nothing
338342
case fr of
343+
#if __GLASGOW_HASKELL__ < 808
339344
Found (ModLocation (Just src) _ _) _ -> do
345+
#else
346+
Found (ModLocation (Just src) _ _ _) _ -> do
347+
#endif
340348
fp <- reverseMapFile rfm src
341349

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

src/Haskell/Ide/Engine/Version.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE TemplateHaskell #-}
3-
{-# LANGUAGE LambdaCase #-}
43
{-# LANGUAGE OverloadedStrings #-}
54
-- | Information and display strings for HIE's version
65
-- and the current project's version

0 commit comments

Comments
 (0)