Skip to content

Ghc 8.8.1 support #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@

[submodule "submodules/ghc-mod"]
path = submodules/ghc-mod
url = https://github.com/fendor/ghc-mod.git
url = https://github.com/fendor/ghc-mod.git
[submodule "submodules/apply-refact"]
path = submodules/apply-refact
url = https://github.com/mpickering/apply-refact.git
1 change: 1 addition & 0 deletions app/MainHie.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Main where
Expand Down
1 change: 1 addition & 0 deletions hie-plugin-api/Haskell/Ide/Engine/Ghc.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down
1 change: 1 addition & 0 deletions hie-plugin-api/Haskell/Ide/Engine/PluginsIdeMonads.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveAnyClass #-}
Expand Down
2 changes: 1 addition & 1 deletion install/shake.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Used to provide a different environment for the shake build script
resolver: lts-14.11 # GHC 8.6.5
resolver: lts-14.17 # GHC 8.6.5
packages:
- .

Expand Down
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/LSP/Completions.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
Expand Down
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Plugin/Brittany.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE OverloadedStrings #-}
module Haskell.Ide.Engine.Plugin.Brittany where

Expand Down
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Plugin/Generic.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
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 NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
Expand Down Expand Up @@ -106,7 +107,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 @@ -151,8 +156,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 @@ -161,7 +173,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 @@ -173,9 +189,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
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Plugin/HsImport.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
Expand Down
6 changes: 6 additions & 0 deletions src/Haskell/Ide/Engine/Plugin/Package.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
Expand All @@ -19,6 +20,7 @@ import qualified Data.ByteString as B
import Data.Foldable
import Data.List
import qualified Data.HashMap.Strict as HM
import qualified Data.Set as S
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Maybe
Expand Down Expand Up @@ -301,7 +303,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
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down
1 change: 1 addition & 0 deletions src/Haskell/Ide/Engine/Scheduler.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ExistentialQuantification #-}
Expand Down
6 changes: 6 additions & 0 deletions src/Haskell/Ide/Engine/Support/HieExtras.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -336,7 +338,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: 1 addition & 0 deletions src/Haskell/Ide/Engine/Transport/LspStdio.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
Expand Down
2 changes: 1 addition & 1 deletion stack-8.6.5.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-14.16
resolver: lts-14.17
packages:
- .
- hie-plugin-api
Expand Down
31 changes: 9 additions & 22 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2019-09-21 # Last GHC 8.6.5
resolver: nightly-2019-12-18
packages:
- .
- hie-plugin-api
Expand All @@ -7,31 +7,18 @@ extra-deps:
# - ./submodules/HaRe
- ./submodules/cabal-helper
- ./submodules/ghc-mod/ghc-project-types

- deque-0.4.3
- ansi-terminal-0.8.2
- ./submodules/apply-refact
- hie-bios-0.3.2
- bytestring-trie-0.2.5.0
- ansi-wl-pprint-0.6.8.2
- brittany-0.12.1.0
- cabal-plan-0.5.0.0
- constrained-dynamic-0.1.0.0
- fclabels-2.0.3.3
- floskell-0.10.2
- ghc-lib-parser-8.8.1
- haddock-api-2.22.0
- haskell-lsp-0.19.0.0
- haskell-lsp-types-0.19.0.0
- hie-bios-0.3.2
- hlint-2.2.4
- fold-debounce-0.2.0.9
- haddock-api-2.23.0
- haddock-library-1.8.0
- hoogle-5.0.17.13
- hsimport-0.11.0
- lsp-test-0.9.0.0
- monad-dijkstra-0.1.1.2@rev:1
- syz-0.2.0.0
- temporary-1.2.1.1
- clock-0.7.2
- ghc-exactprint-0.6.2 # for HaRe
- extra-1.6.18
- unix-compat-0.5.2
- yaml-0.11.1.2
- monad-dijkstra-0.1.1.2

flags:
haskell-ide-engine:
Expand Down
1 change: 1 addition & 0 deletions submodules/apply-refact
Submodule apply-refact added at 1acf7e