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

GHC 8.8 support #1482

Merged
merged 23 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure/linux-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
matrix:
stack-def:
YAML_FILE: stack.yaml
stack-8.8.1:
YAML_FILE: stack-8.8.1.yaml
stack-8.6.5:
YAML_FILE: stack-8.6.5.yaml
stack-8.6.4:
Expand Down
2 changes: 2 additions & 0 deletions .azure/macos-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
matrix:
stack-def:
YAML_FILE: stack.yaml
stack-8.8.1:
YAML_FILE: stack-8.8.1.yaml
stack-8.6.5:
YAML_FILE: stack-8.6.5.yaml
stack-8.6.4:
Expand Down
5 changes: 3 additions & 2 deletions .azure/windows-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ jobs:
vmImage: windows-2019
strategy:
matrix:
stack-def:
YAML_FILE: stack.yaml
# We can't use stack.yaml while it uses ghc-8.8.1
# stack-def:
# YAML_FILE: stack.yaml
stack-8.6.5:
YAML_FILE: stack-8.6.5.yaml
stack-8.6.4:
Expand Down
11 changes: 4 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:
cabal:
working_directory: ~/build
docker:
- image: quay.io/haskell_works/ghc-8.6.5
- image: haskell:8.8.1
steps:
- checkout
- run:
Expand All @@ -161,18 +161,15 @@ jobs:
- restore-cache:
keys:
- cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
- run:
name: Cabal version
command: cabal --version
- run:
name: Update
command: cabal new-update
command: cabal update
- run:
name: Configure
command: cabal new-configure --enable-tests
command: cabal configure --enable-tests
- run:
name: Build
command: cabal new-build -j1 # need j1, else ghc-lib-parser triggers OOM
command: cabal build -j1 # need j1, else ghc-lib-parser triggers OOM
no_output_timeout: 30m
- save_cache:
key: cabal-{{ .Environment.HIE_CACHE }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
Expand Down
3 changes: 3 additions & 0 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Main where

import qualified Control.Exception as E
import Control.Monad
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#endif
import Data.Version (showVersion)
import qualified Data.Text as T
import qualified Data.Text.IO as T
Expand Down
6 changes: 5 additions & 1 deletion hie-plugin-api/Haskell/Ide/Engine/Ghc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Control.Monad ( when )
import Data.IORef
import qualified Data.Map.Strict as Map
-- import qualified Data.IntMap.Strict as IM
import Data.Semigroup ((<>), Semigroup)
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Aeson
Expand All @@ -37,7 +36,12 @@ import Haskell.Ide.Engine.PluginUtils
import DynFlags
import GHC
import qualified HscTypes

#if __GLASGOW_HASKELL__ < 808
import Data.Semigroup ((<>), Semigroup)
import Outputable (renderWithStyle)
#endif

import Language.Haskell.LSP.Types ( NormalizedUri(..), toNormalizedUri )

import Haskell.Ide.Engine.GhcUtils
Expand Down
13 changes: 9 additions & 4 deletions hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveAnyClass #-}
Expand Down Expand Up @@ -111,13 +112,17 @@ import qualified Data.List as List
import Data.Dynamic ( Dynamic )
import qualified Data.Map as Map
import Data.Maybe
import Data.Monoid ( (<>) )

import qualified Data.Set as S
import Data.String
import qualified Data.Text as T
import Data.Typeable ( TypeRep
, Typeable
)
import Data.Typeable ( TypeRep )

#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ( (<>) )
import Data.Typeable ( Typeable )
#endif

import System.Directory
import GhcMonad
import GHC.Generics
Expand Down
4 changes: 2 additions & 2 deletions install/src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ getHieVersions = do
& mapMaybe
(T.stripPrefix stackYamlPrefix >=> T.stripSuffix stackYamlSuffix)
& map T.unpack
-- the following line excludes `8.6.3` on windows systems
& filter (\p -> not isWindowsSystem || p /= "8.6.3")
-- the following line excludes `8.6.3` and `8.8.1` on windows systems
& filter (\p -> not (isWindowsSystem && p `elem` ["8.6.3","8.8.1"]))
& sort
return hieVersions

Expand Down
3 changes: 3 additions & 0 deletions src/Haskell/Ide/Engine/Completions.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
Expand All @@ -23,7 +24,9 @@ import qualified Data.List as List
import qualified Data.Text as T
import qualified Data.Map as Map
import Data.Maybe
#if __GLASGOW_HASKELL__ < 808
import Data.Semigroup (Semigroup(..))
#endif
import Data.Typeable
import GHC.Generics ( Generic )

Expand Down
5 changes: 5 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
Expand All @@ -19,7 +20,11 @@ import Control.Monad.IO.Class
import Control.Monad.Trans.Except
import Data.Aeson hiding (Error)
import Data.Maybe

#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#endif

import qualified Data.Text as T
import GHC.Generics
import Haskell.Ide.Engine.MonadFunctions
Expand Down
3 changes: 2 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/Brittany.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import Haskell.Ide.Engine.PluginUtils
import Language.Haskell.Brittany
import qualified Language.Haskell.LSP.Types as J
import qualified Language.Haskell.LSP.Types.Lens as J
import System.FilePath (FilePath, takeDirectory)

import System.FilePath
import Data.Maybe (maybeToList)

brittanyDescriptor :: PluginId -> PluginDescriptor
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import Data.Function
import qualified Data.HashMap.Strict as HM
import Data.List
import Data.Maybe
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#endif
import qualified Data.Text as T
import Name
import GHC.Generics
Expand Down
2 changes: 2 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/GhcMod.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ module Haskell.Ide.Engine.Plugin.GhcMod
) where

import Data.Aeson
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#endif
import GHC.Generics
import qualified Haskell.Ide.Engine.Ghc as HIE
import Haskell.Ide.Engine.MonadTypes
Expand Down
25 changes: 24 additions & 1 deletion src/Haskell/Ide/Engine/Plugin/Haddock.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -107,7 +108,11 @@ getDocsForName df name = do
case mf of
Nothing -> return Nothing
Just f -> do
#if __GLASGOW_HASKELL__ >= 808
ehi <- readInterfaceFile nameCacheFromIdeM f True
#else
ehi <- readInterfaceFile nameCacheFromIdeM f
#endif
case ehi of
Left message -> do
debugm $ "Haddock docs couldn't be loaded as readInterfaceFile failed with: " ++ message
Expand Down Expand Up @@ -152,8 +157,15 @@ prettyprintType n t = T.unlines
, "```\n"
]

unwrap :: Foldable w => w a -> a
unwrap = foldl1 (const id)

renderDocs :: MDoc Name -> T.Text
#if __GLASGOW_HASKELL__ >= 808
renderDocs = markup renderMarkDown . _doc . fmap unwrap
#else
renderDocs = markup renderMarkDown . _doc
#endif

renderMarkDown :: DocMarkup Name T.Text
renderMarkDown =
Expand All @@ -162,7 +174,11 @@ renderMarkDown =
, markupParagraph = (<> "\n\n")
, markupAppend = mappend
, markupIdentifier = surround "`" . T.pack . getOccString
#if __GLASGOW_HASKELL__ >= 808
, markupIdentifierUnchecked = T.pack . occNameString . snd . unwrap
#else
, markupIdentifierUnchecked = T.pack . occNameString . snd
#endif
, markupModule = surround "**" . T.pack
, markupWarning = surround "*"
, markupEmphasis = surround "*"
Expand All @@ -174,9 +190,16 @@ renderMarkDown =
, markupDefList = T.unlines . map (\(a, b) -> a <> " :: " <> b)
, markupCodeBlock = \x -> "\n```haskell\n" <> removeInner x <> "\n```\n"
, markupHyperlink = \h ->
T.pack $ maybe
#if __GLASGOW_HASKELL__ >= 808
let url = T.pack $ hyperlinkUrl h
in maybe
url
(\l -> "["<>l<>"]("<>url<>")")
#else
T.pack $ maybe
(hyperlinkUrl h)
(\l -> "["<>l<>"]("<>hyperlinkUrl h<>")")
#endif
(hyperlinkLabel h)
, markupAName = T.pack
, markupPic = const ""
Expand Down
3 changes: 3 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/HsImport.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
Expand All @@ -13,7 +14,9 @@ import Control.Monad
import Data.Aeson
import Data.Foldable
import Data.Maybe
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ( (<>) )
#endif
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified GHC.Generics as Generics
Expand Down
8 changes: 8 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import qualified Data.HashMap.Strict as HM
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Maybe
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#else
import qualified Data.Set as S
#endif
#if MIN_VERSION_Cabal(2,2,0)
import Distribution.PackageDescription.Parsec
import Distribution.Types.VersionRange
Expand Down Expand Up @@ -297,7 +301,11 @@ editCabalPackage file modulePath pkgName fileMap = do
-- Add it to the bottom of the dependencies list
-- TODO: we could sort the depencies and then insert it,
-- or insert it in order iff the list is already sorted.
#if __GLASGOW_HASKELL__ >= 808
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion S.empty]
#else
newDeps = oldDeps ++ [Dependency (mkPackageName (T.unpack dep)) anyVersion]
#endif

-- | Provide a code action to add a package to the local package.yaml or cabal file.
-- Reads from diagnostics the unknown import module path and searches for it on Hoogle.
Expand Down
3 changes: 3 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
Expand All @@ -8,7 +9,9 @@ module Haskell.Ide.Engine.Plugin.Pragmas where
import Control.Lens
import Data.Aeson
import qualified Data.HashMap.Strict as H
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid ((<>))
#endif
import qualified Data.Text as T
import qualified GHC.Generics as Generics
import Haskell.Ide.Engine.MonadTypes hiding (_range)
Expand Down
9 changes: 6 additions & 3 deletions src/Haskell/Ide/Engine/Scheduler.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ExistentialQuantification #-}
Expand Down Expand Up @@ -25,9 +26,11 @@ where
import Control.Concurrent.Async
import GHC.Conc
import qualified Control.Concurrent.STM as STM
import Control.Monad.IO.Class ( liftIO
, MonadIO
)
import Control.Monad.IO.Class ( MonadIO )
#if __GLASGOW_HASKELL__ < 808
import Control.Monad.IO.Class ( liftIO )
#endif

import Control.Monad.Reader.Class ( ask
, MonadReader
)
Expand Down
6 changes: 5 additions & 1 deletion src/Haskell/Ide/Engine/Server.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -32,7 +33,10 @@ import Data.Default
import Data.Foldable
import qualified Data.Map as Map
import Data.Maybe
import Data.Semigroup (Semigroup(..), Option(..), option)
import Data.Semigroup (Option(..), option)
#if __GLASGOW_HASKELL__ < 808
import Data.Semigroup (Semigroup(..), )
#endif
import qualified Data.Set as S
import qualified Data.SortedList as SL
import qualified Data.Text as T
Expand Down
10 changes: 9 additions & 1 deletion src/Haskell/Ide/Engine/Support/HieExtras.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -25,7 +26,11 @@ module Haskell.Ide.Engine.Support.HieExtras
, getFormattingPlugin
) where

#if __GLASGOW_HASKELL__ < 808
import Data.Semigroup (Semigroup(..))
import Var
#endif

import ConLike
import Control.Monad.Reader
import Control.Monad.Except
Expand Down Expand Up @@ -62,7 +67,6 @@ import Packages
import SrcLoc
import TcEnv
import Type
import Var
import Module hiding (getModule)

-- ---------------------------------------------------------------------
Expand Down Expand Up @@ -336,7 +340,11 @@ gotoModule rfm mn = do
flushFinderCaches env
findImportedModule env mn Nothing
case fr of
#if __GLASGOW_HASKELL__ < 808
Found (ModLocation (Just src) _ _) _ -> do
#else
Found (ModLocation (Just src) _ _ _) _ -> do
#endif
fp <- reverseMapFile rfm src

let r = Range (Position 0 0) (Position 0 0)
Expand Down
1 change: 0 additions & 1 deletion src/Haskell/Ide/Engine/Version.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
-- | Information and display strings for HIE's version
-- and the current project's version
Expand Down
Loading