Skip to content

Commit

Permalink
Update code for GHC 9.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
JakuJ committed Aug 27, 2024
1 parent e380c3e commit 3966f33
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ jobs:
- uses: haskell/actions/setup@v1
name: Setup Haskell Stack
with:
ghc-version: 9.2.2
ghc-version: 9.6.6
enable-stack: true
stack-version: 'latest'

- uses: actions/[email protected]
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-9.2.2-stack
key: ${{ runner.os }}-9.6.6-stack

- name: Install dependencies
run: |
Expand Down
23 changes: 12 additions & 11 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,37 @@ module Main (
) where

import ArgParse
import Control.Monad.IO.Class (liftIO)
import Data.Version (showVersion)
import Control.Monad.IO.Class (liftIO)
import Data.Version (showVersion)
import Language.LSP.Protocol.Types
import Language.LSP.Server
import Language.LSP.Types
import qualified Paths_rsl_language_server as Paths
import Raise.Handlers (handlers)
import qualified Paths_rsl_language_server as Paths
import Raise.Handlers (handlers)

syncOptions :: TextDocumentSyncOptions
syncOptions = TextDocumentSyncOptions
{ _openClose = Just True
, _change = Just TdSyncIncremental
, _change = Just TextDocumentSyncKind_Incremental
, _willSave = Just False
, _willSaveWaitUntil = Just False
, _save = Just $ InR $ SaveOptions $ Just False
}

lspOptions :: Options
lspOptions = defaultOptions
{ textDocumentSync = Just syncOptions
, executeCommandCommands = Just []
{ optTextDocumentSync = Just syncOptions
}

serverDef :: Bool -> ServerDefinition ()
serverDef compile = ServerDefinition
{ onConfigurationChange = const $ pure $ Right ()
{ parseConfig = const $ const $ Right ()
, onConfigChange = const $ pure ()
, defaultConfig = ()
, configSection = "rsl-language-server"
, doInitialize = \env _ -> pure $ Right env
, staticHandlers = handlers compile
, staticHandlers = const $ handlers compile
, interpretHandler = \env -> Iso (runLspT env) liftIO
, options = lspOptions
, defaultConfig = undefined
}

main :: IO Int
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rsl-language-server
version: 0.1.1.2
version: 0.1.2.0
github: "JakuJ/rsl-language-server"
license: BSD3
author: "Jakub Janaszkiewicz"
Expand Down
2 changes: 1 addition & 1 deletion rsl-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: rsl-language-server
version: 0.1.1.2
version: 0.1.2.0
description: Please see the README on GitHub at <https://github.com/JakuJ/rsl-language-server#readme>
homepage: https://github.com/JakuJ/rsl-language-server#readme
bug-reports: https://github.com/JakuJ/rsl-language-server/issues
Expand Down
15 changes: 9 additions & 6 deletions src/Raise/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ module Raise.CodeLens (
registerLenses
) where

import Control.Monad (void)
import qualified Data.Text as T
import Control.Monad.IO.Class

Check warning on line 5 in src/Raise/CodeLens.hs

View workflow job for this annotation

GitHub Actions / ubuntu

The import of ‘Control.Monad.IO.Class’ is redundant
import qualified Data.Text as T
import Language.LSP.Protocol.Message
import Language.LSP.Protocol.Types
import Language.LSP.Server
import Language.LSP.Types

regOpts :: CodeLensRegistrationOptions
regOpts = CodeLensRegistrationOptions Nothing Nothing (Just False)
regOpts = CodeLensRegistrationOptions (InR Null) Nothing (Just False)

registerCommand :: T.Text -> T.Text -> CodeLens
registerCommand name command = CodeLens
{ _range = mkRange 0 0 0 100
, _command = Just $ Command name command Nothing
, _xdata = Nothing
, _data_ = Nothing
}

cmdList :: [(T.Text, T.Text)]
Expand All @@ -26,4 +27,6 @@ cmdList = [ ("Typecheck", "raise.typeCheck")
registerLenses :: LspM () ()
registerLenses = do
let rsp = map (uncurry registerCommand) cmdList
void $ registerCapability STextDocumentCodeLens regOpts $ \_ responder -> responder (Right (List rsp))
_ <- registerCapability SMethod_TextDocumentCodeLens regOpts $ \_ responder -> do
responder (Right (InL rsp))
pure ()
20 changes: 11 additions & 9 deletions src/Raise/DiagnosticParser.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
module Raise.DiagnosticParser where

import Control.Monad (void)
import Data.Foldable (asum)
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Data.Void (Void)
import Language.LSP.Types
import Control.Monad (void)
import Data.Foldable (asum)
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Data.Void (Void)
import Language.LSP.Protocol.Types
import Text.Megaparsec
import Text.Megaparsec.Char
import Text.Megaparsec.Char.Lexer (skipLineComment)
import Text.Megaparsec.Char.Lexer (skipLineComment)

type Parser = Parsec Void T.Text

mkDiagnostic :: UInt -> UInt -> T.Text -> Diagnostic
mkDiagnostic row column msg = Diagnostic
{ _range = Range (Position row column) (Position row column)
, _severity = Just DsError
, _severity = Just DiagnosticSeverity_Error
, _code = Nothing
, _codeDescription = Nothing
, _source = Just "rsl-language-server"
, _message = msg
, _tags = Nothing
, _relatedInformation = Just $ List []
, _relatedInformation = Just []
, _data_ = Nothing
}

-- Discarded output
Expand Down
24 changes: 12 additions & 12 deletions src/Raise/Diagnostics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ module Raise.Diagnostics (
diagnosticHandler
) where

import Control.Lens ((^.))
import Control.Monad.IO.Class (liftIO)
import Data.Either (fromRight)
import Data.Maybe (fromJust)
import qualified Data.Text as T
import Language.LSP.Diagnostics (partitionBySource)
import Control.Lens ((^.))
import Control.Monad.IO.Class (liftIO)
import Data.Either (fromRight)
import Data.Maybe (fromJust)
import qualified Data.Text as T
import Language.LSP.Diagnostics (partitionBySource)
import qualified Language.LSP.Protocol.Lens as J
import qualified Language.LSP.Protocol.Types as J
import Language.LSP.Server
import qualified Language.LSP.Types as J
import qualified Language.LSP.Types.Lens as J
import Raise.DiagnosticParser (parseRSLTC)
import System.Process (readProcessWithExitCode)
import Raise.DiagnosticParser (parseRSLTC)
import System.Process (readProcessWithExitCode)

runTool :: String -> [String] -> IO T.Text
runTool tool args = do
Expand All @@ -30,8 +30,8 @@ runCompiler path = runTool "rsltc" ["-m", path]
sendDiagnostics :: Bool -> J.NormalizedUri -> FilePath -> LspM () ()
sendDiagnostics compile fileUri filePath = do
tcDiags <- fromRight [] . parseRSLTC <$> liftIO (runChecker filePath)
compilerDiags <- if not compile then pure [] else
fmap (\x -> x {J._severity = Just J.DsWarning} ) . fromRight [] . parseRSLTC <$> liftIO (runCompiler filePath)
compilerDiags <- if not compile then pure [] else
fmap (\x -> x {J._severity = Just J.DiagnosticSeverity_Warning} ) . fromRight [] . parseRSLTC <$> liftIO (runCompiler filePath)
let diags = tcDiags ++ compilerDiags
if null diags then
flushDiagnosticsBySource 100 (Just "rsl-language-server")
Expand Down
12 changes: 6 additions & 6 deletions src/Raise/Handlers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module Raise.Handlers (
handlers
) where

import Language.LSP.Protocol.Message
import Language.LSP.Server
import Language.LSP.Types
import Raise.CodeLens (registerLenses)
import Raise.Diagnostics (diagnosticHandler)
import Raise.CodeLens (registerLenses)
import Raise.Diagnostics (diagnosticHandler)


handlers :: Bool -> Handlers (LspM ())
handlers compile = mconcat
[ notificationHandler SInitialized $ const registerLenses
, notificationHandler STextDocumentDidSave $ diagnosticHandler compile
, notificationHandler STextDocumentDidOpen $ diagnosticHandler compile
[ notificationHandler SMethod_Initialized $ const registerLenses
, notificationHandler SMethod_TextDocumentDidSave $ diagnosticHandler compile
, notificationHandler SMethod_TextDocumentDidOpen $ diagnosticHandler compile
]
13 changes: 2 additions & 11 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
resolver: nightly-2022-06-06
resolver: lts-22.33

compiler: ghc-9.2.2
compiler: ghc-9.6.6
compiler-check: match-exact

packages:
- .

extra-deps:
- lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088
- lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504
- lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663
- rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034
- text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788
- Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459
- parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429
59 changes: 5 additions & 54 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,10 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages:
- completed:
hackage: lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088
pantry-tree:
size: 1417
sha256: 92dccca5b6429616c0467d7c0dc665001d67cda76250bc70d7d30025c28d4216
original:
hackage: lsp-1.4.0.0@sha256:d992cb88d6212f113baf372404c141a6bea14c436baa64ea6e4f01b6188c575b,5088
- completed:
hackage: lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504
pantry-tree:
size: 4225
sha256: 9b4ee01ae646c359ac24551816f6e83a22519c503fc0b4d1da5e46d135abf985
original:
hackage: lsp-types-1.4.0.1@sha256:b902952df7becc1827947ee3ff1cd8c746aa8f9f80db330db20e2fdf1b6089e8,4504
- completed:
hackage: lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663
pantry-tree:
size: 1559
sha256: 7fba61926846deb098a82b51e58f127ae9c53256db881d446c1a76c85ba2ecc7
original:
hackage: lsp-test-0.14.0.2@sha256:d62d2af45508f04c5fcad23e469c45b37ca19760cee15b025a0eb499cbd28050,4663
- completed:
hackage: rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034
pantry-tree:
size: 667
sha256: 8f8650b21381dee11be10d327b8df1999f1ba00e303cd1ed3ed52dfd63e1ca69
original:
hackage: rope-utf16-splay-0.4.0.0@sha256:2237ca21b950f5a45971f09ea2d38532a8e06949c82629095351e4bff5207aed,2034
- completed:
hackage: text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788
pantry-tree:
size: 7364
sha256: 894b84358fbad3cb8c16f224d3d8b7a1d7b6bcae68cda5a9998dd964904a6560
original:
hackage: text-2.0@sha256:86e64bc76fefb8f0f6529d28ddf24b2a29d43591a8b9b7c7094f481a0db2fb7d,7788
- completed:
hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459
pantry-tree:
size: 19757
sha256: b250a53bdb56844f047a2927833bb565b936a289abfa85dfc2a63148d776368a
original:
hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459
- completed:
hackage: parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429
pantry-tree:
size: 2630
sha256: cbddc1e3c5ada6925354850cc0a8fadcd8643689098a504a0ed25ef9e0b932b8
original:
hackage: parsec-3.1.15.0@sha256:a162d4cc8884014ba35192545cad293af0529fe11497aad8834bbaaa3dfffc26,4429
packages: []
snapshots:
- completed:
size: 605110
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/6/6.yaml
sha256: 26ea900ee8601fee24ff84981e92f304d384c73ee32d5504299133b5eb177e87
original: nightly-2022-06-06
sha256: 098936027eaa1ef14e2b8eb39d9933a973894bb70a68684a1bbf00730249879b
size: 720001
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/33.yaml
original: lts-22.33

0 comments on commit 3966f33

Please sign in to comment.