From 1e7ed333db1ac4d494efb356ac9cf572bf45179c Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sun, 11 Jun 2023 13:21:14 +0200 Subject: [PATCH 01/15] Bumped Stack snapshot to LTS 18.28 - dhall-lsp-server: Require lsp>=1.5.0.0. --- dhall-lsp-server/dhall-lsp-server.cabal | 8 ++--- dhall-lsp-server/src/Dhall/LSP/Handlers.hs | 8 ++--- dhall-lsp-server/src/Dhall/LSP/Server.hs | 39 ++++++++++++++-------- dhall/src/Dhall/Syntax/Expr.hs | 3 ++ dhall/src/Dhall/Syntax/Expr.hs-boot | 5 +++ dhall/src/Dhall/TH.hs | 18 +++++----- stack.yaml | 8 ++++- 7 files changed, 58 insertions(+), 31 deletions(-) diff --git a/dhall-lsp-server/dhall-lsp-server.cabal b/dhall-lsp-server/dhall-lsp-server.cabal index bf8b11b9b..a44e37d00 100644 --- a/dhall-lsp-server/dhall-lsp-server.cabal +++ b/dhall-lsp-server/dhall-lsp-server.cabal @@ -46,15 +46,14 @@ library , aeson-pretty >= 0.8.7 && < 0.9 , base >= 4.11 && < 5 , bytestring >= 0.10.8.2 && < 0.12 + , co-log-core >= 0.3.1.0 && < 0.4 , containers >= 0.5.11.0 && < 0.7 , data-default >= 0.7.1.1 && < 0.8 , directory >= 1.2.2.0 && < 1.4 , dhall >= 1.38.0 && < 1.43 , dhall-json >= 1.4 && < 1.8 , filepath >= 1.4.2 && < 1.5 - , lsp >= 1.2.0.0 && < 1.5 - , rope-utf16-splay >= 0.3.1.0 && < 0.5 - , hslogger >= 1.2.10 && < 1.4 + , lsp >= 1.5.0.0 && < 2 , lens >= 4.16.1 && < 5.3 -- megaparsec follows SemVer: https://github.com/mrkkrp/megaparsec/issues/469#issuecomment-927918469 , megaparsec >= 7.0.2 && < 10 @@ -62,6 +61,7 @@ library , network-uri >= 2.6.1.0 && < 2.7 , prettyprinter >= 1.7.0 && < 1.8 , text >= 1.2.3.0 && < 2.1 + , text-rope >= 0.2 && < 0.3 , transformers >= 0.5.5.0 && < 0.6 , unordered-containers >= 0.2.9.0 && < 0.3 , uri-encode >= 1.5.0.5 && < 1.6 @@ -104,7 +104,7 @@ Test-Suite tests GHC-Options: -Wall Build-Depends: base , - lsp-types >= 1.2.0.0 && < 1.5 , + lsp-types >= 1.2.0.0 && < 1.7 , hspec >= 2.7 && < 2.11 , lsp-test >= 0.13.0.0 && < 0.15 , tasty >= 0.11.2 && < 1.5 , diff --git a/dhall-lsp-server/src/Dhall/LSP/Handlers.hs b/dhall-lsp-server/src/Dhall/LSP/Handlers.hs index fe37522f5..a5c778919 100644 --- a/dhall-lsp-server/src/Dhall/LSP/Handlers.hs +++ b/dhall-lsp-server/src/Dhall/LSP/Handlers.hs @@ -75,7 +75,7 @@ import Text.Megaparsec (SourcePos (..), unPos) import qualified Data.Aeson as Aeson import qualified Data.HashMap.Strict as HashMap import qualified Data.Map.Strict as Map -import qualified Data.Rope.UTF16 as Rope +import qualified Data.Text.Utf16.Rope as Rope import qualified Data.Text as Text import qualified Language.LSP.Server as LSP import qualified Language.LSP.Types as LSP.Types @@ -617,12 +617,12 @@ didSaveTextDocumentNotificationHandler = -- this handler is a stab to prevent `lsp:no handler for:` messages. initializedHandler :: Handlers HandlerM -initializedHandler = +initializedHandler = LSP.notificationHandler SInitialized \_ -> return () -- this handler is a stab to prevent `lsp:no handler for:` messages. workspaceChangeConfigurationHandler :: Handlers HandlerM -workspaceChangeConfigurationHandler = +workspaceChangeConfigurationHandler = LSP.notificationHandler SWorkspaceDidChangeConfiguration \_ -> return () -- this handler is a stab to prevent `lsp:no handler for:` messages. @@ -639,7 +639,7 @@ handleErrorWithDefault :: (Either a1 b -> HandlerM a2) -> b -> HandlerM a2 -> HandlerM a2 -handleErrorWithDefault respond _default = flip catchE handler +handleErrorWithDefault respond _default = flip catchE handler where handler (Log, _message) = do let _xtype = MtLog diff --git a/dhall-lsp-server/src/Dhall/LSP/Server.hs b/dhall-lsp-server/src/Dhall/LSP/Server.hs index e31933579..e91b1a3a7 100644 --- a/dhall-lsp-server/src/Dhall/LSP/Server.hs +++ b/dhall-lsp-server/src/Dhall/LSP/Server.hs @@ -1,10 +1,12 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE RecordWildCards #-} {-| This is the entry point for the LSP server. -} module Dhall.LSP.Server(run) where +import Colog.Core (LogAction, WithSeverity) import Control.Monad.IO.Class (liftIO) import Data.Aeson (fromJSON) import Data.Default @@ -22,23 +24,28 @@ import Dhall.LSP.Handlers , cancelationHandler ) import Dhall.LSP.State -import Language.LSP.Server (Options(..), ServerDefinition(..), type (<~>)(..)) +import Language.LSP.Server (LspServerLog, Options(..), ServerDefinition(..), type (<~>)(..)) import Language.LSP.Types +import Prettyprinter (Doc, Pretty, pretty, viaShow) import System.Exit (ExitCode(..)) +import System.IO (stdin, stdout) +import qualified Colog.Core as Colog import qualified Control.Concurrent.MVar as MVar import qualified Control.Monad.Trans.Except as Except import qualified Control.Monad.Trans.State.Strict as State import qualified Data.Aeson as Aeson import qualified Data.Text as Text +import qualified Language.LSP.Logging as LSP import qualified Language.LSP.Server as LSP import qualified System.Exit as Exit -import qualified System.Log.Logger -- | The main entry point for the LSP server. run :: Maybe FilePath -> IO () -run mlog = do - setupLogger mlog +run = withLogger $ \ioLogger -> do + let clientLogger = Colog.cmap (fmap (Text.pack . show . pretty)) LSP.defaultClientLogger + + let lspLogger = clientLogger <> Colog.hoistLogAction liftIO ioLogger state <- MVar.newMVar initialState @@ -117,20 +124,26 @@ run mlog = do backward = liftIO - exitCode <- LSP.runServer ServerDefinition{..} + exitCode <- LSP.runServerWithHandles ioLogger lspLogger stdin stdout ServerDefinition{..} case exitCode of 0 -> return () n -> Exit.exitWith (ExitFailure n) --- | sets the output logger. --- | if no filename is provided then logger is disabled, if input is string `[OUTPUT]` then log goes to stderr, --- | which then redirects inside VSCode to the output pane of the plugin. -setupLogger :: Maybe FilePath -> IO () -- TODO: ADD verbosity -setupLogger Nothing = pure () -setupLogger (Just "[OUTPUT]") = LSP.setupLogger Nothing [] System.Log.Logger.DEBUG -setupLogger file = LSP.setupLogger file [] System.Log.Logger.DEBUG - +-- | Retrieve the output logger. +-- If no filename is provided then logger is disabled, if input is the string +-- `[OUTPUT]` then we log to stderr. +-- TODO: ADD verbosity +withLogger :: (LogAction IO (WithSeverity LspServerLog) -> IO ()) -> Maybe FilePath -> IO () +withLogger k = \case + Nothing -> k (Colog.LogAction (const (pure ()))) + Just "[OUTPUT]" -> k' Colog.logStringStderr + Just fp -> Colog.withLogStringFile fp k' + where + k' = k . Colog.cmap (show . prettyMsg) + + prettyMsg :: Pretty a => WithSeverity a -> Doc ann + prettyMsg l = "[" <> viaShow (Colog.getSeverity l) <> "] " <> pretty (Colog.getMsg l) -- Tells the LSP client to notify us about file changes. Handled behind the -- scenes by haskell-lsp (in Language.Haskell.LSP.VFS); we don't handle the diff --git a/dhall/src/Dhall/Syntax/Expr.hs b/dhall/src/Dhall/Syntax/Expr.hs index 6398ff019..6153032b2 100644 --- a/dhall/src/Dhall/Syntax/Expr.hs +++ b/dhall/src/Dhall/Syntax/Expr.hs @@ -1,10 +1,12 @@ {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE StandaloneKindSignatures #-} module Dhall.Syntax.Expr ( Expr(..) ) where import Data.ByteString (ByteString) +import Data.Kind (Type) import Data.List.NonEmpty (NonEmpty (..)) import Data.Sequence (Seq) import Data.String (IsString (..)) @@ -41,6 +43,7 @@ import qualified Data.Time as Time * If @a = `Data.Void.Void`@ then the code has no `Dhall.Syntax.Import.Import`s -} +type Expr :: Type -> Type -> Type data Expr s a -- | > Const c ~ c = Const Const diff --git a/dhall/src/Dhall/Syntax/Expr.hs-boot b/dhall/src/Dhall/Syntax/Expr.hs-boot index c83bb7a6a..99a6548f0 100644 --- a/dhall/src/Dhall/Syntax/Expr.hs-boot +++ b/dhall/src/Dhall/Syntax/Expr.hs-boot @@ -1,3 +1,8 @@ +{-# LANGUAGE StandaloneKindSignatures #-} + module Dhall.Syntax.Expr where +import Data.Kind (Type) + +type Expr :: Type -> Type -> Type data Expr s a diff --git a/dhall/src/Dhall/TH.hs b/dhall/src/Dhall/TH.hs index f1b1ffd79..a27e5f8c5 100644 --- a/dhall/src/Dhall/TH.hs +++ b/dhall/src/Dhall/TH.hs @@ -61,7 +61,7 @@ import qualified Numeric.Natural import qualified Prettyprinter.Render.String as Pretty import qualified System.IO - + {-| This fully resolves, type checks, and normalizes the expression, so the resulting AST is self-contained. @@ -161,9 +161,9 @@ toNestedHaskellType typeParams haskellTypes = loop , " \n" , "... which did not fit any of the above criteria." ] - + message dhallType = Pretty.renderString (Dhall.Pretty.layout (document dhallType)) - + loop dhallType = case dhallType of Bool -> return (ConT ''Bool) @@ -204,7 +204,7 @@ toNestedHaskellType typeParams haskellTypes = loop haskellElementType <- loop dhallElementType return (AppT haskellAppType haskellElementType) - + Var v | Just (V param index) <- List.find (v ==) typeParams -> do let name = Syntax.mkName $ (Text.unpack param) ++ (show index) @@ -256,7 +256,7 @@ toDeclaration generateOptions@GenerateOptions{..} haskellTypes typ = MultipleConstructors{..} -> uncurry (fromMulti typeName) $ getTypeParams code where getTypeParams = first numberConsecutive . getTypeParams_ [] - + getTypeParams_ acc (Lam _ (FunctionBinding _ v _ _ _) rest) = getTypeParams_ (v:acc) rest getTypeParams_ acc rest = (acc, rest) @@ -284,16 +284,16 @@ toDeclaration generateOptions@GenerateOptions{..} haskellTypes typ = fromSingle typeName constructorName typeParams dhallType = do constructor <- toConstructor typeParams generateOptions haskellTypes typeName (constructorName, Just dhallType) - + toDataD typeName typeParams [constructor] - + fromMulti typeName typeParams dhallType = case dhallType of Union kts -> do constructors <- traverse (toConstructor typeParams generateOptions haskellTypes typeName) (Dhall.Map.toList kts) toDataD typeName typeParams constructors - - _ -> fail $ message dhallType + + _ -> fail $ message dhallType message dhallType = Pretty.renderString (Dhall.Pretty.layout $ document dhallType) diff --git a/stack.yaml b/stack.yaml index 887dcd8a3..39c769388 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-18.18 +resolver: lts-18.28 packages: - dhall - dhall-bash @@ -11,12 +11,18 @@ packages: - dhall-toml - dhall-yaml extra-deps: + - co-log-core-0.3.2.0 - hnix-0.16.0 - hnix-store-core-0.5.0.0 - hnix-store-remote-0.5.0.0 + - lsp-1.5.0.0 + - lsp-types-1.5.0.0 + - lsp-test-0.14.1.0 - lucid-2.11.0 - relude-1.0.0.1@sha256:35bcdaf14018e79f11e712b0e2314c1aac79976f28f4adc179985457493557d5,11569 - semialign-1.2@sha256:9afb6eb7e50db7ca34d7c4108aec0f643dae2caaaa80394b44ffdd643315685c,2721 + - text-rope-0.2 + - typerep-map-0.5.0.0 nix: packages: - ncurses From dd63be6f6466c6253e82b1b994042981967bc79a Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sun, 11 Jun 2023 13:54:25 +0200 Subject: [PATCH 02/15] Updated GitHub Actions --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c1626f1f..4db81cf0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: runs-on: ${{ matrix.os.runner }} steps: - name: "Checkout repository" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: true - id: setup-haskell-cabal @@ -35,7 +35,7 @@ jobs: with: enable-stack: true - name: "Cache" - uses: actions/cache@v2 + uses: actions/cache@v3 with: key: ${{ matrix.os.runner }}-${{ hashFiles('stack.yaml') }}-${{ env.cache_generation }} restore-keys: | @@ -143,7 +143,7 @@ jobs: package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}" package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}" - name: "Upload package" - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: 'dhall-${{runner.os}}.${{matrix.os.file-extension}}' path: 'dhall-*${{runner.os}}.${{matrix.os.file-extension}}' From 2a45457b90370fe341835d358afe5108a378e790 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sat, 19 Aug 2023 13:47:07 +0200 Subject: [PATCH 03/15] Added Stack configuration for GHC 9.2.8 --- stack.ghc-8.10.yaml | 33 +++++++++++++++++++++++++++++++++ stack.ghc-9.2.yaml | 34 ++++++++++++++++++++++++++++++++++ stack.yaml | 34 +--------------------------------- 3 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 stack.ghc-8.10.yaml create mode 100644 stack.ghc-9.2.yaml mode change 100644 => 120000 stack.yaml diff --git a/stack.ghc-8.10.yaml b/stack.ghc-8.10.yaml new file mode 100644 index 000000000..39c769388 --- /dev/null +++ b/stack.ghc-8.10.yaml @@ -0,0 +1,33 @@ +resolver: lts-18.28 +packages: + - dhall + - dhall-bash + - dhall-csv + - dhall-docs + - dhall-json + - dhall-lsp-server + - dhall-nix + - dhall-openapi + - dhall-toml + - dhall-yaml +extra-deps: + - co-log-core-0.3.2.0 + - hnix-0.16.0 + - hnix-store-core-0.5.0.0 + - hnix-store-remote-0.5.0.0 + - lsp-1.5.0.0 + - lsp-types-1.5.0.0 + - lsp-test-0.14.1.0 + - lucid-2.11.0 + - relude-1.0.0.1@sha256:35bcdaf14018e79f11e712b0e2314c1aac79976f28f4adc179985457493557d5,11569 + - semialign-1.2@sha256:9afb6eb7e50db7ca34d7c4108aec0f643dae2caaaa80394b44ffdd643315685c,2721 + - text-rope-0.2 + - typerep-map-0.5.0.0 +nix: + packages: + - ncurses + - zlib +flags: + # https://github.com/RyanGlScott/mintty/issues/4 + mintty: + Win32-2-13-1: false diff --git a/stack.ghc-9.2.yaml b/stack.ghc-9.2.yaml new file mode 100644 index 000000000..00b138156 --- /dev/null +++ b/stack.ghc-9.2.yaml @@ -0,0 +1,34 @@ +resolver: lts-20.26 +packages: + - dhall + - dhall-bash + - dhall-csv + - dhall-docs + - dhall-json + - dhall-lsp-server + - dhall-nix + - dhall-openapi + - dhall-toml + - dhall-yaml +extra-deps: + - github: haskell-nix/hnix + commit: 2adbc502e62e755ca0372c913e6278ebe564d7d2 + - chronos-1.1.5 + - hashing-0.1.1.0 + - hnix-store-core-0.6.1.0 + - hnix-store-remote-0.6.0.0 + - logict-0.7.0.3 + - lsp-test-0.14.1.0 + - optparse-applicative-0.16.1.0 + - saltine-0.2.1.0 + - tomland-1.3.3.2 + - typerep-map-0.5.0.0 + - validation-selective-0.1.0.2 +nix: + packages: + - ncurses + - zlib +flags: + # https://github.com/RyanGlScott/mintty/issues/4 + mintty: + Win32-2-13-1: false diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 39c769388..000000000 --- a/stack.yaml +++ /dev/null @@ -1,33 +0,0 @@ -resolver: lts-18.28 -packages: - - dhall - - dhall-bash - - dhall-csv - - dhall-docs - - dhall-json - - dhall-lsp-server - - dhall-nix - - dhall-openapi - - dhall-toml - - dhall-yaml -extra-deps: - - co-log-core-0.3.2.0 - - hnix-0.16.0 - - hnix-store-core-0.5.0.0 - - hnix-store-remote-0.5.0.0 - - lsp-1.5.0.0 - - lsp-types-1.5.0.0 - - lsp-test-0.14.1.0 - - lucid-2.11.0 - - relude-1.0.0.1@sha256:35bcdaf14018e79f11e712b0e2314c1aac79976f28f4adc179985457493557d5,11569 - - semialign-1.2@sha256:9afb6eb7e50db7ca34d7c4108aec0f643dae2caaaa80394b44ffdd643315685c,2721 - - text-rope-0.2 - - typerep-map-0.5.0.0 -nix: - packages: - - ncurses - - zlib -flags: - # https://github.com/RyanGlScott/mintty/issues/4 - mintty: - Win32-2-13-1: false diff --git a/stack.yaml b/stack.yaml new file mode 120000 index 000000000..14b62e3b5 --- /dev/null +++ b/stack.yaml @@ -0,0 +1 @@ +stack.ghc-9.2.yaml \ No newline at end of file From d812e7ca22298e21190585bcee84c3aa756249bb Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sat, 19 Aug 2023 14:00:20 +0200 Subject: [PATCH 04/15] Added CI job for GHC 8.10 --- .github/workflows/main.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4db81cf0b..9616ab4ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,11 @@ jobs: archive-command: '7z a -tzip' file-extension: 'zip' executable-extension: '.exe' + stack-yaml: + - "stack.yaml" + include: + - runner: "ubuntu-latest" + stack-yaml: "stack.ghc-8.10.yaml" fail-fast: false name: ${{ matrix.os.runner }} runs-on: ${{ matrix.os.runner }} @@ -37,7 +42,7 @@ jobs: - name: "Cache" uses: actions/cache@v3 with: - key: ${{ matrix.os.runner }}-${{ hashFiles('stack.yaml') }}-${{ env.cache_generation }} + key: ${{ matrix.os.runner }}-${{ hashFiles(matrix.stack-yaml) }}-${{ env.cache_generation }} restore-keys: | ${{ matrix.os.runner }}- path: | @@ -71,7 +76,7 @@ jobs: # We use --test --no-run-tests to avoid re-building all the local packages in the # subsequent test step. # See https://github.com/commercialhaskell/stack/issues/4977. - stack build --test --no-run-tests --copy-bins --local-bin-path ./bin "${package}" + stack --stack-yaml "${{matrix.stack-yaml}}" build --test --no-run-tests --copy-bins --local-bin-path ./bin "${package}" done - name: "Run tests" shell: bash @@ -93,7 +98,7 @@ jobs: continue fi - stack test "${package}" + stack --stack-yaml "${{matrix.stack-yaml}}" test "${package}" done - name: "Prepare packaging" shell: bash @@ -103,6 +108,7 @@ jobs: cp dhall-docs/src/Dhall/data/man/dhall-docs.1 share/man/man1/ - id: package name: "Create packages" + if: ${{ matrix.stack-yaml == "stack.yaml" }} shell: bash run: | packages=( @@ -143,6 +149,7 @@ jobs: package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}" package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}" - name: "Upload package" + if: ${{ matrix.stack-yaml == "stack.yaml" }} uses: actions/upload-artifact@v3 with: name: 'dhall-${{runner.os}}.${{matrix.os.file-extension}}' From 0ec0603a227d401e4fc654bfb5df1f86e18feee3 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sun, 20 Aug 2023 14:47:28 +0200 Subject: [PATCH 05/15] Allow passing extra arguments to the doctest test suites --- dhall-docs/doctest/Main.hs | 13 +++++++++---- dhall-lsp-server/doctest/Main.hs | 15 +++++++++------ dhall-toml/doctest/Main.hs | 14 ++++++++++++-- dhall/doctest/Main.hs | 22 ++++++++++++---------- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/dhall-docs/doctest/Main.hs b/dhall-docs/doctest/Main.hs index eaac1d683..e01a50cb7 100644 --- a/dhall-docs/doctest/Main.hs +++ b/dhall-docs/doctest/Main.hs @@ -1,18 +1,23 @@ -module Main where +module Main (main) where import System.FilePath (()) import qualified GHC.IO.Encoding import qualified System.Directory +import qualified System.Environment import qualified System.IO import qualified Test.DocTest main :: IO () main = do GHC.IO.Encoding.setLocaleEncoding System.IO.utf8 - pwd <- System.Directory.getCurrentDirectory + args <- System.Environment.getArgs + pwd <- System.Directory.getCurrentDirectory prefix <- System.Directory.makeAbsolute pwd - Test.DocTest.doctest + let src = prefix "src" + + Test.DocTest.doctest $ [ "--fast" - , prefix "src" + ] <> args <> + [ src ] diff --git a/dhall-lsp-server/doctest/Main.hs b/dhall-lsp-server/doctest/Main.hs index 20d594862..b858ae470 100644 --- a/dhall-lsp-server/doctest/Main.hs +++ b/dhall-lsp-server/doctest/Main.hs @@ -1,23 +1,26 @@ -module Main where +module Main (main) where import System.FilePath (()) import qualified GHC.IO.Encoding import qualified System.Directory +import qualified System.Environment import qualified System.IO import qualified Test.DocTest main :: IO () main = do - GHC.IO.Encoding.setLocaleEncoding System.IO.utf8 - pwd <- System.Directory.getCurrentDirectory + args <- System.Environment.getArgs + pwd <- System.Directory.getCurrentDirectory prefix <- System.Directory.makeAbsolute pwd + let src = prefix "src" - Test.DocTest.doctest + Test.DocTest.doctest $ [ "--fast" , "-XOverloadedStrings" , "-XRecordWildCards" - , "-i" <> (prefix "src") - , prefix "src/Dhall/LSP/Backend/Diagnostics.hs" + ] <> args <> + [ "-i" <> src + , src "Dhall/LSP/Backend/Diagnostics.hs" ] diff --git a/dhall-toml/doctest/Main.hs b/dhall-toml/doctest/Main.hs index 225dcbcc1..6f968330a 100644 --- a/dhall-toml/doctest/Main.hs +++ b/dhall-toml/doctest/Main.hs @@ -1,14 +1,24 @@ -module Main where +module Main (main) where import System.FilePath (()) +import qualified GHC.IO.Encoding import qualified System.Directory +import qualified System.Environment +import qualified System.IO import qualified Test.DocTest main :: IO () main = do + GHC.IO.Encoding.setLocaleEncoding System.IO.utf8 + args <- System.Environment.getArgs pwd <- System.Directory.getCurrentDirectory prefix <- System.Directory.makeAbsolute pwd let src = prefix "src" - Test.DocTest.doctest [ "--fast", "-i" <> src, src ] + Test.DocTest.doctest $ + [ "--fast" + ] <> args <> + [ "-i" <> src + , src + ] diff --git a/dhall/doctest/Main.hs b/dhall/doctest/Main.hs index d6d4ac57f..053d79411 100644 --- a/dhall/doctest/Main.hs +++ b/dhall/doctest/Main.hs @@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-} -module Main where +module Main (main) where import System.FilePath (()) @@ -13,10 +13,11 @@ import qualified Test.Mockery.Directory main :: IO () main = do - GHC.IO.Encoding.setLocaleEncoding System.IO.utf8 - pwd <- System.Directory.getCurrentDirectory + args <- System.Environment.getArgs + pwd <- System.Directory.getCurrentDirectory prefix <- System.Directory.makeAbsolute pwd + let src = prefix "src" System.Environment.setEnv "XDG_CACHE_HOME" (pwd ".cache") @@ -34,11 +35,12 @@ main = do , "in { name = \"Simon\", favoriteFont = Font.`Comic Sans` } : Person" ] - Test.DocTest.doctest + Test.DocTest.doctest $ [ "-DWITH_HTTP" , "-DUSE_HTTP_CLIENT_TLS" , "--fast" - , prefix "ghc-src" + ] <> args <> + [ prefix "ghc-src" -- Unfortunately we cannot target the entire @src@ directory. -- The reason is that src/Dhall/Version.hs depends on @@ -47,11 +49,11 @@ main = do -- Instead, we target a selection of modules whose combined module -- dependency tree covers all modules that contain doctests. - -- , prefix "src" - , "-i" <> (prefix "src") + -- , src + , "-i" <> src #if __GLASGOW_HASKELL__ >= 806 - , prefix "src/Dhall/Deriving.hs" + , src "Dhall/Deriving.hs" #endif - , prefix "src/Dhall/Tags.hs" - , prefix "src/Dhall/Tutorial.hs" + , src "Dhall/Tags.hs" + , src "Dhall/Tutorial.hs" ] From fce8f6b39829dd89251fbb0235e158c6b98be0b2 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sun, 20 Aug 2023 16:40:51 +0200 Subject: [PATCH 06/15] Cabal: Use hnix from Git repository --- cabal.project | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cabal.project b/cabal.project index e732b7522..b70ea8492 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,17 @@ -packages: ./dhall ./dhall-bash ./dhall-json ./dhall-yaml ./dhall-nix ./dhall-docs ./dhall-openapi ./dhall-nixpkgs ./dhall-csv ./dhall-toml ./dhall-lsp-server +packages: + ./dhall + ./dhall-bash + ./dhall-csv + ./dhall-docs + ./dhall-json + ./dhall-lsp-server + ./dhall-nix + ./dhall-nixpkgs + ./dhall-openapi + ./dhall-toml + ./dhall-yaml + +source-repository-package + type: git + location: https://github.com/haskell-nix/hnix.git + tag: 2adbc502e62e755ca0372c913e6278ebe564d7d2 From 2083581c727a37a4f4e7da24e7d940063e3ca307 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 15:44:34 +0200 Subject: [PATCH 07/15] Use single quotes in GHA condition --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9616ab4ab..8abb163ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -108,7 +108,7 @@ jobs: cp dhall-docs/src/Dhall/data/man/dhall-docs.1 share/man/man1/ - id: package name: "Create packages" - if: ${{ matrix.stack-yaml == "stack.yaml" }} + if: ${{ matrix.stack-yaml == 'stack.yaml' }} shell: bash run: | packages=( @@ -149,7 +149,7 @@ jobs: package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}" package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}" - name: "Upload package" - if: ${{ matrix.stack-yaml == "stack.yaml" }} + if: ${{ matrix.stack-yaml == 'stack.yaml' }} uses: actions/upload-artifact@v3 with: name: 'dhall-${{runner.os}}.${{matrix.os.file-extension}}' From 9c213f96eddb863be5e44145e3740887e674079c Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 15:54:16 +0200 Subject: [PATCH 08/15] GHA: Try nested os.runner --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8abb163ff..e0b67a0d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,8 @@ jobs: stack-yaml: - "stack.yaml" include: - - runner: "ubuntu-latest" + - os: + runner: "ubuntu-latest" stack-yaml: "stack.ghc-8.10.yaml" fail-fast: false name: ${{ matrix.os.runner }} From 468b82c5521a29a7bdef66747af40357cee13be3 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 15:58:11 +0200 Subject: [PATCH 09/15] GHA: Include used stack.yaml file in job name --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0b67a0d3..d627dbc41 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: runner: "ubuntu-latest" stack-yaml: "stack.ghc-8.10.yaml" fail-fast: false - name: ${{ matrix.os.runner }} + name: ${{ matrix.os.runner }} - ${{ matrix.stack-yaml }} runs-on: ${{ matrix.os.runner }} steps: - name: "Checkout repository" From 0ac8cd87265b8d4383edad6587f0227b33533dca Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 16:25:04 +0200 Subject: [PATCH 10/15] Updated mergify config --- .mergify.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 66af7d8f9..3995d681f 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -4,9 +4,9 @@ queue_rules: - check-success=hydra # Mergify explicitly recommends listing each status check separately: # https://docs.mergify.io/conditions/#validating-all-status-checks - - check-success=macOS-latest - - check-success=ubuntu-latest - - check-success=windows-latest + - check-success=macOS-latest - stack.yaml + - check-success=ubuntu-latest - stack.yaml + - check-success=windows-latest - stack.yaml pull_request_rules: - actions: queue: From fe7ea1bffaab38d39603afa92019b596ebfb1ad9 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 16:40:28 +0200 Subject: [PATCH 11/15] Also skip package preparation step if we are not using stack.yaml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d627dbc41..1f30024d2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -102,6 +102,7 @@ jobs: stack --stack-yaml "${{matrix.stack-yaml}}" test "${package}" done - name: "Prepare packaging" + if: ${{ matrix.stack-yaml == 'stack.yaml' }} shell: bash run: | mkdir -p share/man/man1 From 91d6d67c0b3e5cd78a1ed40b0dc65360ce571dac Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Wed, 25 Oct 2023 17:48:26 +0200 Subject: [PATCH 12/15] Updated used actions --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f30024d2..7de224fd6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,14 +32,15 @@ jobs: runs-on: ${{ matrix.os.runner }} steps: - name: "Checkout repository" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - id: setup-haskell-cabal name: "Setup Haskell environment" - uses: haskell/actions/setup@v2.4.6 + uses: haskell-actions/setup@v2.5 with: enable-stack: true + stack-version: "latest" - name: "Cache" uses: actions/cache@v3 with: From 916a66bc66b45edeb4ea9988905df42978562ef6 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sat, 23 Dec 2023 15:37:13 +0100 Subject: [PATCH 13/15] Added text-rope.nix --- nix/packages/text-rope.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 nix/packages/text-rope.nix diff --git a/nix/packages/text-rope.nix b/nix/packages/text-rope.nix new file mode 100644 index 000000000..125d30f24 --- /dev/null +++ b/nix/packages/text-rope.nix @@ -0,0 +1,15 @@ +{ mkDerivation, base, deepseq, lib, random, tasty, tasty-bench +, tasty-quickcheck, text, vector +}: +mkDerivation { + pname = "text-rope"; + version = "0.2"; + sha256 = "b14422855e9cc375a31c22758454013ac629671331de6ccb77b496509bcae78b"; + enableSeparateDataOutput = true; + libraryHaskellDepends = [ base deepseq text vector ]; + testHaskellDepends = [ base tasty tasty-quickcheck text ]; + benchmarkHaskellDepends = [ base random tasty-bench text ]; + homepage = "https://github.com/Bodigrim/text-rope"; + description = "Text lines and ropes"; + license = lib.licenses.bsd3; +} From d206e7fdd77de5027fe480797641e8e9315a85b1 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sat, 23 Dec 2023 16:21:01 +0100 Subject: [PATCH 14/15] Added co-log-core.nix and lsp.nix --- nix/packages/co-log-core.nix | 11 +++++++++++ nix/packages/lsp.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 nix/packages/co-log-core.nix create mode 100644 nix/packages/lsp.nix diff --git a/nix/packages/co-log-core.nix b/nix/packages/co-log-core.nix new file mode 100644 index 000000000..c84775dc9 --- /dev/null +++ b/nix/packages/co-log-core.nix @@ -0,0 +1,11 @@ +{ mkDerivation, base, doctest, Glob, lib }: +mkDerivation { + pname = "co-log-core"; + version = "0.3.2.1"; + sha256 = "7e12a8e02a02c0e2c13e8def101ee8243c6c033392cd3031b63fe5db5168ff87"; + libraryHaskellDepends = [ base ]; + testHaskellDepends = [ base doctest Glob ]; + homepage = "https://github.com/co-log/co-log-core"; + description = "Composable Contravariant Comonadic Logging Library"; + license = lib.licenses.mpl20; +} diff --git a/nix/packages/lsp.nix b/nix/packages/lsp.nix new file mode 100644 index 000000000..f86462477 --- /dev/null +++ b/nix/packages/lsp.nix @@ -0,0 +1,28 @@ +{ mkDerivation, aeson, async, attoparsec, base, bytestring +, co-log-core, containers, data-default, directory, exceptions +, filepath, hashable, hspec, hspec-discover, lens, lib, lsp-types +, mtl, prettyprinter, random, sorted-list, stm, temporary, text +, text-rope, transformers, unliftio-core, unordered-containers +, uuid +}: +mkDerivation { + pname = "lsp"; + version = "1.6.0.0"; + sha256 = "896803766e8ceabeacc72743f4b92cf7766b2a1f09be270b29d0a39692b00470"; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + aeson async attoparsec base bytestring co-log-core containers + data-default directory exceptions filepath hashable lens lsp-types + mtl prettyprinter random sorted-list stm temporary text text-rope + transformers unliftio-core unordered-containers uuid + ]; + testHaskellDepends = [ + base containers hspec sorted-list text text-rope + unordered-containers + ]; + testToolDepends = [ hspec-discover ]; + homepage = "https://github.com/haskell/lsp"; + description = "Haskell library for the Microsoft Language Server Protocol"; + license = lib.licenses.mit; +} From fb1c7227882c791133b68320be26b9231ddfaa64 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sat, 23 Dec 2023 16:24:43 +0100 Subject: [PATCH 15/15] Added lsp-types.nix --- nix/packages/lsp-types.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 nix/packages/lsp-types.nix diff --git a/nix/packages/lsp-types.nix b/nix/packages/lsp-types.nix new file mode 100644 index 000000000..665a400ff --- /dev/null +++ b/nix/packages/lsp-types.nix @@ -0,0 +1,24 @@ +{ mkDerivation, aeson, base, binary, containers, data-default +, deepseq, Diff, dlist, exceptions, filepath, hashable, hspec +, hspec-discover, lens, lib, mod, mtl, network-uri, QuickCheck +, quickcheck-instances, safe, scientific, some, template-haskell +, text, tuple, unordered-containers +}: +mkDerivation { + pname = "lsp-types"; + version = "1.6.0.1"; + sha256 = "47d084f3a56195706381b51ad2f5d1b22a958238f3e5519625dbc54a2503f670"; + libraryHaskellDepends = [ + aeson base binary containers data-default deepseq Diff dlist + exceptions filepath hashable lens mod mtl network-uri safe + scientific some template-haskell text unordered-containers + ]; + testHaskellDepends = [ + aeson base filepath hspec lens network-uri QuickCheck + quickcheck-instances text tuple + ]; + testToolDepends = [ hspec-discover ]; + homepage = "https://github.com/haskell/lsp"; + description = "Haskell library for the Microsoft Language Server Protocol, data types"; + license = lib.licenses.mit; +}