Date: Thursday, September 29, 2022 @ 15:32:34 Author: felixonmars Revision: 1316308
upgpkg: haskell-lsp-types 1.3.0.1-122: rebuild with aeson 2.0.3.0, aeson-diff 1.1.0.11, bower-json 1.1.0.0, http2 3.0.3, hoauth2 2.1.0, jose 0.9, microlens-aeson 2.4.0, postgresql-binary 0.12.5, postgrest 10.0.0, req 3.10.0, swagger2 2.8.1 Added: haskell-lsp-types/trunk/lsp-types-aeson-2.patch Modified: haskell-lsp-types/trunk/PKGBUILD -------------------------+ PKGBUILD | 9 +- lsp-types-aeson-2.patch | 164 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+), 3 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2022-09-29 15:27:12 UTC (rev 1316307) +++ PKGBUILD 2022-09-29 15:32:34 UTC (rev 1316308) @@ -3,7 +3,7 @@ _hkgname=lsp-types pkgname=haskell-lsp-types pkgver=1.3.0.1 -pkgrel=121 +pkgrel=122 pkgdesc="Haskell library for the Microsoft Language Server Protocol, data types" url="https://github.com/haskell/lsp" license=("MIT") @@ -13,11 +13,14 @@ 'haskell-hslogger' 'haskell-lens' '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=('074a2a383efefd3754ed1c835af913e1ab5fee9f634cb343f392bc8148f1a62030777dbb1104cd0e60cec1405d2cc5067c8fb00f2e902a3ffa52601ff7b02c2b') +source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz" + lsp-types-aeson-2.patch) +sha512sums=('074a2a383efefd3754ed1c835af913e1ab5fee9f634cb343f392bc8148f1a62030777dbb1104cd0e60cec1405d2cc5067c8fb00f2e902a3ffa52601ff7b02c2b' + '491c235382551e6c5e7969c307e275f95ca3d427eeda3143217914dba43ec498c29f83246ed42787c0700b891f4aec5759e46867986224d6304f3bd0e7460763') prepare() { cd $_hkgname-$pkgver + patch -p2 -i ../lsp-types-aeson-2.patch gen-setup } Added: lsp-types-aeson-2.patch =================================================================== --- lsp-types-aeson-2.patch (rev 0) +++ lsp-types-aeson-2.patch 2022-09-29 15:32:34 UTC (rev 1316308) @@ -0,0 +1,164 @@ +From b2353bc99d31dd41e3f4a03b993bc13b2e2f4802 Mon Sep 17 00:00:00 2001 +From: Michael Peyton Jones <[email protected]> +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]
