proto-lens-protobuf-types 0.7.2.2 → 0.7.2.3
raw patch · 3 files changed
+18/−13 lines, 3 files
Files
- Changelog.md +7/−0
- proto-lens-protobuf-types.cabal +4/−4
- src/Data/ProtoLens/Any.hs +7/−9
Changelog.md view
@@ -1,5 +1,12 @@ # Changelog for `proto-lens-protobuf-types` +## v0.7.2.3+- Support GHC 9.12.+- Support GHC 9.14.+- Fix `Data.ProtoLens.Any` to not import `IsLabels` instance, allowing+ use of other `IsLabels` instances (e.g. from `generic-lens`) alongside+ `proto-lens-protobuf-types`.+ ## v0.7.2.2 - Bump upper bounds for ghc-9.10.
proto-lens-protobuf-types.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: proto-lens-protobuf-types-version: 0.7.2.2+version: 0.7.2.3 synopsis: Basic protocol buffer message types. description: This package provides bindings standard protocol message types, for use with the proto-lens library. category: Data@@ -39,8 +39,8 @@ custom-setup setup-depends:- Cabal >=3 && <3.13- , base >=4.10 && <4.21+ Cabal >=3 && <3.17+ , base >=4.10 && <4.23 , proto-lens-setup ==0.4.* library@@ -101,7 +101,7 @@ build-tool-depends: proto-lens-protoc:proto-lens-protoc build-depends:- base >=4.10 && <4.21+ base >=4.10 && <4.23 , lens-family >=1.2 && <2.2 , proto-lens ==0.7.* , proto-lens-runtime ==0.7.*
src/Data/ProtoLens/Any.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-}@@ -17,17 +16,16 @@ #endif import qualified Data.Text as Text import Data.Text (Text)-import Data.Typeable (Typeable) import Data.ProtoLens ( decodeMessage , defMessage , encodeMessage , Message(..) )-import Data.ProtoLens.Labels () import Data.Proxy (Proxy(..)) import Lens.Family2 ((&), (.~), (^.)) import Proto.Google.Protobuf.Any+import Proto.Google.Protobuf.Any_Fields (typeUrl, value) -- | Packs the given message into an 'Any' using the default type URL prefix -- "type.googleapis.com".@@ -41,8 +39,8 @@ packWithPrefix :: forall a . Message a => Text -> a -> Any packWithPrefix prefix x = defMessage- & #typeUrl .~ (prefix <> "/" <> name)- & #value .~ encodeMessage x+ & typeUrl .~ (prefix <> "/" <> name)+ & value .~ encodeMessage x where name = messageName (Proxy @a) @@ -54,7 +52,7 @@ , actualUrl :: Text -- ^ The typeUrl in the 'Any' being unpacked } | DecodingError Text -- ^ The error from decodeMessage- deriving (Show, Eq, Typeable)+ deriving (Show, Eq) instance Exception UnpackError @@ -64,12 +62,12 @@ -- Ignores the type URL prefix. unpack :: forall a . Message a => Any -> Either UnpackError a unpack a- | expectedName /= snd (Text.breakOnEnd "/" $ a ^. #typeUrl)+ | expectedName /= snd (Text.breakOnEnd "/" $ a ^. typeUrl) = Left DifferentType { expectedMessageType = expectedName- , actualUrl = a ^. #typeUrl+ , actualUrl = a ^. typeUrl }- | otherwise = case decodeMessage (a ^. #value) of+ | otherwise = case decodeMessage (a ^. value) of Left e -> Left $ DecodingError $ Text.pack e Right x -> Right x where