Date: Sunday, February 12, 2023 @ 09:47:17 Author: felixonmars Revision: 1399958
archrelease: copy trunk to community-x86_64 Added: haskell-lsp-types1.4/repos/community-x86_64/ haskell-lsp-types1.4/repos/community-x86_64/PKGBUILD (from rev 1399957, haskell-lsp-types1.4/trunk/PKGBUILD) haskell-lsp-types1.4/repos/community-x86_64/lsp-types-aeson-2.patch (from rev 1399957, haskell-lsp-types1.4/trunk/lsp-types-aeson-2.patch) -------------------------+ PKGBUILD | 53 ++++++++++++++ lsp-types-aeson-2.patch | 164 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) Copied: haskell-lsp-types1.4/repos/community-x86_64/PKGBUILD (from rev 1399957, haskell-lsp-types1.4/trunk/PKGBUILD) =================================================================== --- community-x86_64/PKGBUILD (rev 0) +++ community-x86_64/PKGBUILD 2023-02-12 09:47:17 UTC (rev 1399958) @@ -0,0 +1,53 @@ +# Maintainer: Felix Yan <felixonm...@archlinux.org> + +_hkgname=lsp-types +pkgname=haskell-lsp-types1.4 +pkgver=1.4.0.1 +pkgrel=1 +pkgdesc="Haskell library for the Microsoft Language Server Protocol, data types" +url="https://github.com/haskell/lsp" +license=("MIT") +arch=('x86_64') +depends=('ghc-libs' 'haskell-aeson' 'haskell-data-default' 'haskell-diff' 'haskell-dlist' + 'haskell-hashable' 'haskell-hslogger' 'haskell-lens' 'haskell-mod' 'haskell-network-uri' + 'haskell-rope-utf16-splay' 'haskell-scientific' 'haskell-some' 'haskell-temporary' + 'haskell-unordered-containers') +makedepends=('ghc' 'uusi') +source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz") +sha512sums=('5049f9755f9eb6afaabde1f675b76416e3f8ed1cc7d9bb8ad8ed243918dde13861d21196e21ffd855dbf6971c0e5ddab0465cc0a437127e6980ede2f9aeb29fc') + +prepare() { + cd $_hkgname-$pkgver + gen-setup +} + +build() { + cd $_hkgname-$pkgver + + runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \ + --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \ + --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \ + --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \ + --ghc-option='-pie' + + runhaskell Setup build $MAKEFLAGS + runhaskell Setup register --gen-script + runhaskell Setup unregister --gen-script + sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh + sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh +} + +check() { + cd $_hkgname-$pkgver + runhaskell Setup test --show-details=direct +} + +package() { + cd $_hkgname-$pkgver + + install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh + install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh + runhaskell Setup copy --destdir="$pkgdir" + install -D -m644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/ + rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE +} Copied: haskell-lsp-types1.4/repos/community-x86_64/lsp-types-aeson-2.patch (from rev 1399957, haskell-lsp-types1.4/trunk/lsp-types-aeson-2.patch) =================================================================== --- community-x86_64/lsp-types-aeson-2.patch (rev 0) +++ community-x86_64/lsp-types-aeson-2.patch 2023-02-12 09:47:17 UTC (rev 1399958) @@ -0,0 +1,164 @@ +From b2353bc99d31dd41e3f4a03b993bc13b2e2f4802 Mon Sep 17 00:00:00 2001 +From: Michael Peyton Jones <m...@michaelpj.com> +Date: Sat, 30 Oct 2021 18:08:23 +0100 +Subject: [PATCH] Aeson 2 compatibility + +We get compatibility with both <2 and >=2 by using only functions that +appear in both, which don't make assumptions about the structure of +objects. + +Fixes #356 +--- + lsp-types/src/Language/LSP/Types/Common.hs | 3 +- + lsp-types/src/Language/LSP/Types/Message.hs | 6 +-- + lsp-types/src/Language/LSP/Types/Parsing.hs | 56 +++++++++++---------- + lsp/example/Reactor.hs | 5 +- + 4 files changed, 35 insertions(+), 35 deletions(-) + +diff --git a/lsp-types/src/Language/LSP/Types/Common.hs b/lsp-types/src/Language/LSP/Types/Common.hs +index b57b39e7..62c3a2d6 100644 +--- a/lsp-types/src/Language/LSP/Types/Common.hs ++++ b/lsp-types/src/Language/LSP/Types/Common.hs +@@ -9,7 +9,6 @@ module Language.LSP.Types.Common where + import Control.Applicative + import Control.DeepSeq + import Data.Aeson +-import qualified Data.HashMap.Strict as HashMap + import GHC.Generics + + -- | A terser, isomorphic data type for 'Either', that does not get tagged when +@@ -55,5 +54,5 @@ instance ToJSON Empty where + toJSON Empty = Null + instance FromJSON Empty where + parseJSON Null = pure Empty +- parseJSON (Object o) | HashMap.null o = pure Empty ++ parseJSON (Object o) | o == mempty = pure Empty + parseJSON _ = fail "expected 'null' or '{}'" +diff --git a/lsp-types/src/Language/LSP/Types/Message.hs b/lsp-types/src/Language/LSP/Types/Message.hs +index 452dbc3b..f3277c51 100644 +--- a/lsp-types/src/Language/LSP/Types/Message.hs ++++ b/lsp-types/src/Language/LSP/Types/Message.hs +@@ -55,12 +55,12 @@ import Language.LSP.Types.WatchedFiles + import Language.LSP.Types.WorkspaceEdit + import Language.LSP.Types.WorkspaceFolders + import Language.LSP.Types.WorkspaceSymbol +-import qualified Data.HashMap.Strict as HM + + import Data.Kind + import Data.Aeson + import Data.Aeson.TH + import Data.Text (Text) ++import Data.String + import GHC.Generics + + -- --------------------------------------------------------------------- +@@ -274,8 +274,8 @@ deriving instance Show (MessageParams m) => Show (RequestMessage m) + -- | Replace a missing field in an object with a null field, to simplify parsing + -- This is a hack to allow other types than Maybe to work like Maybe in allowing the field to be missing. + -- See also this issue: https://github.com/haskell/aeson/issues/646 +-addNullField :: Text -> Value -> Value +-addNullField s (Object o) = Object $ HM.insertWith (\_new old -> old) s Null o ++addNullField :: String -> Value -> Value ++addNullField s (Object o) = Object $ o <> fromString s .= Null + addNullField _ v = v + + instance (FromJSON (MessageParams m), FromJSON (SMethod m)) => FromJSON (RequestMessage m) where +diff --git a/lsp-types/src/Language/LSP/Types/Parsing.hs b/lsp-types/src/Language/LSP/Types/Parsing.hs +index ff7559f2..b1f6ac75 100644 +--- a/lsp-types/src/Language/LSP/Types/Parsing.hs ++++ b/lsp-types/src/Language/LSP/Types/Parsing.hs +@@ -14,13 +14,13 @@ + {-# LANGUAGE TupleSections #-} + {-# LANGUAGE TypeApplications #-} + {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} ++{-# LANGUAGE ScopedTypeVariables #-} + + module Language.LSP.Types.Parsing where + + import Language.LSP.Types.LspId + import Language.LSP.Types.Method + import Language.LSP.Types.Message +-import qualified Data.HashMap.Strict as HM + + import Data.Aeson + import Data.Aeson.Types +@@ -90,25 +90,26 @@ Notification | jsonrpc | | method | params? + {-# INLINE parseServerMessage #-} + parseServerMessage :: LookupFunc FromClient a -> Value -> Parser (FromServerMessage' a) + parseServerMessage lookupId v@(Object o) = do +- case HM.lookup "method" o of +- Just cmd -> do +- -- Request or Notification +- SomeServerMethod m <- parseJSON cmd ++ methMaybe <- o .:! "method" ++ idMaybe <- o .:! "id" ++ case methMaybe of ++ -- Request or Notification ++ Just (SomeServerMethod m) -> + case splitServerMethod m of + IsServerNot -> FromServerMess m <$> parseJSON v + IsServerReq -> FromServerMess m <$> parseJSON v +- IsServerEither +- | HM.member "id" o -- Request +- , SCustomMethod cm <- m -> ++ IsServerEither | SCustomMethod cm <- m -> do ++ case idMaybe of ++ -- Request ++ Just _ -> + let m' = (SCustomMethod cm :: SMethod (CustomMethod :: Method FromServer Request)) +- in FromServerMess m' <$> parseJSON v +- | SCustomMethod cm <- m -> ++ in FromServerMess m' <$> parseJSON v ++ Nothing -> + let m' = (SCustomMethod cm :: SMethod (CustomMethod :: Method FromServer Notification)) +- in FromServerMess m' <$> parseJSON v ++ in FromServerMess m' <$> parseJSON v + Nothing -> do +- case HM.lookup "id" o of +- Just i' -> do +- i <- parseJSON i' ++ case idMaybe of ++ Just i -> do + case lookupId i of + Just (m,res) -> clientResponseJSON m $ FromServerRsp res <$> parseJSON v + Nothing -> fail $ unwords ["Failed in looking up response type of", show v] +@@ -118,25 +119,26 @@ parseServerMessage _ v = fail $ unwords ["parseServerMessage expected object, go + {-# INLINE parseClientMessage #-} + parseClientMessage :: LookupFunc FromServer a -> Value -> Parser (FromClientMessage' a) + parseClientMessage lookupId v@(Object o) = do +- case HM.lookup "method" o of +- Just cmd -> do +- -- Request or Notification +- SomeClientMethod m <- parseJSON cmd ++ methMaybe <- o .:! "method" ++ idMaybe <- o .:! "id" ++ case methMaybe of ++ -- Request or Notification ++ Just (SomeClientMethod m) -> + case splitClientMethod m of + IsClientNot -> FromClientMess m <$> parseJSON v + IsClientReq -> FromClientMess m <$> parseJSON v +- IsClientEither +- | HM.member "id" o -- Request +- , SCustomMethod cm <- m -> ++ IsClientEither | SCustomMethod cm <- m -> do ++ case idMaybe of ++ -- Request ++ Just _ -> + let m' = (SCustomMethod cm :: SMethod (CustomMethod :: Method FromClient Request)) +- in FromClientMess m' <$> parseJSON v +- | SCustomMethod cm <- m -> ++ in FromClientMess m' <$> parseJSON v ++ Nothing -> + let m' = (SCustomMethod cm :: SMethod (CustomMethod :: Method FromClient Notification)) +- in FromClientMess m' <$> parseJSON v ++ in FromClientMess m' <$> parseJSON v + Nothing -> do +- case HM.lookup "id" o of +- Just i' -> do +- i <- parseJSON i' ++ case idMaybe of ++ Just i -> do + case lookupId i of + Just (m,res) -> serverResponseJSON m $ FromClientRsp res <$> parseJSON v + Nothing -> fail $ unwords ["Failed in looking up response type of", show v]