HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulegrapesy-1.1.1Haskell2010

Network.GRPC.Common.Protobuf

Common functionality for working with Protobuf

  • 4 types
  • 3 classes
  • 9 values
  • Packagegrapesy-1.1.1
  • Exports16
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceProtobuf.hs
datadata Protobuf serv (meth :: Symbol)
#

Protobuf RPC

This exists only as a type-level marker

Instances8IsRPC, SupportsClientRpc, SupportsServerRpc, HasStreamingType, SupportsStreamingType, Input, …
newtypenewtype Proto msg
#

Wrapper around Protobuf messages and Protobuf enums

Protobuf messages and enums behave differently to normal Haskell datatypes. Fields in messages always have defaults, enums can have unknown values, etc. We therefore mark them at the type-level with this Proto wrapper. Most of the time you can work with Proto values as if the wrapper is not there, because Proto msg inherits Message and Data.ProtoLens.Field HasField instances from msg. For example, you can create a 'Proto Point' value as

p = defMessage
      & #latitude  .~ ..
      & #longitude .~ ..

and access fields from such a value using

p ^. #latitude

as per usual.

One advantage of the Proto wrapper is that we can give blanket instances for all Protobuf messages; we use this to provide GHC.Records HasField and GHC.Records.Compat HasField instances. This means that you can also use OverloadedRecordDot to access fields

p.latitude

or even OverloadedRecordUpdate to set fields

p{latitude = ..}

Constructors

Instances17Bounded, Enum, Eq, Ord, Show, NFData, …
  • HasField (Proto rec) fldName fldType => HasField fldName (Proto rec) fldTypeDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • HasField (Proto rec) fldName fldType => HasField fldName (Proto rec) fldTypeDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Bounded msg => Bounded (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Enum msg => Enum (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Eq msg => Eq (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Ord msg => Ord (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Show msg => Show (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • NFData msg => NFData (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • FieldDefault msg => FieldDefault (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • Message msg => Message (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • MessageEnum msg => MessageEnum (Proto msg)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • (HasField rec fldName x, RewrapField (Describe x) x fldType) => HasField (Proto rec) fldName fldTypeDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • RewrapField ('MkFieldDesc 'LabelImplicit 'NotScalar) a (Proto a)Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • RewrapField ('MkFieldDesc 'LabelOptional 'NotScalar) (Maybe a) (Maybe (Proto a))Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • RewrapField ('MkFieldDesc 'LabelRepeated 'NotScalar) (Vector a) (Vector (Proto a))Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • RewrapField ('MkFieldDesc 'LabelRepeated 'NotScalar) [a] [Proto a]Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf
  • RewrapField ('MkFieldDesc 'LabelMap 'NotScalar) (Map k a) (Map k (Proto a))Defined in grpc-spec-1.0.0 · Network.GRPC.Spec.RPC.Protobuf

Exceptions

5 declarations
datadata ProtobufError a
#

gRPC exception with protobuf-specific error details

See also Status and google.rpc.Status.

Instances6Functor, Foldable, Traversable, Eq, Ord, Show

Re-exports

0 declarations

Data.Function

value(&) :: a -> (a -> b) -> b
#

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

This is a version of flip id, where id is specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is (a -> b) -> a -> b. flipping this yields a -> (a -> b) -> b which is the type signature of &

Examples
Example1 expression
5 & (+1) & show"6"
Example1 expression
sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)3.1406380562059946

Control.Lens

value(.~) :: ASetter s t a b -> b -> s -> t
#

Replace the target of a Lens or all of the targets of a Setter or Traversal with a constant value.

This is an infix version of set, provided for consistency with (.=).

f <$ a ≡ mapped .~ f $ a
Example1 expression
(a,b,c,d) & _4 .~ e(a,b,c,e)
Example1 expression
(42,"world") & _1 .~ "hello"("hello","world")
Example1 expression
(a,b) & both .~ c(c,c)
(.~) :: Setter s t a b    -> b -> s -> t
(.~) :: Iso s t a b       -> b -> s -> t
(.~) :: Lens s t a b      -> b -> s -> t
(.~) :: Traversal s t a b -> b -> s -> t
value(^.) :: s -> Getting a s a -> a
#

View the value pointed to by a Getter or Lens or the result of folding over all the results of a Control.Lens.Fold.Fold or Control.Lens.Traversal.Traversal that points at a monoidal values.

This is the same operation as view with the arguments flipped.

The fixity and semantics are such that subsequent field accesses can be performed with (Prelude..).

Example1 expression
(a,b)^._2b
Example1 expression
("hello","world")^._2"world"
Example2 expressions
import Data.Complex((0, 1 :+ 2), 3)^._1._2.to magnitude2.23606797749979
(^.) ::             s -> Getter s a     -> a
(^.) :: Monoid m => s -> Control.Lens.Fold.Fold s m       -> m
(^.) ::             s -> Control.Lens.Iso.Iso' s a       -> a
(^.) ::             s -> Lens' s a      -> a
(^.) :: Monoid m => s -> Control.Lens.Traversal.Traversal' s m -> m
value(%~) :: ASetter s t a b -> (a -> b) -> s -> t
#

Modifies the target of a Lens or all of the targets of a Setter or Traversal with a user supplied function.

This is an infix version of over.

fmap f ≡ mapped %~ f
fmapDefault f ≡ traverse %~ f
Example1 expression
(a,b,c) & _3 %~ f(a,b,f c)
Example1 expression
(a,b) & both %~ f(f a,f b)
Example1 expression
_2 %~ length $ (1,"hello")(1,5)
Example1 expression
traverse %~ f $ [a,b,c][f a,f b,f c]
Example1 expression
traverse %~ even $ [1,2,3][False,True,False]
Example1 expression
traverse.traverse %~ length $ [["hello","world"],["!!!"]][[5,5],[3]]
(%~) :: Setter s t a b    -> (a -> b) -> s -> t
(%~) :: Iso s t a b       -> (a -> b) -> s -> t
(%~) :: Lens s t a b      -> (a -> b) -> s -> t
(%~) :: Traversal s t a b -> (a -> b) -> s -> t

Data.ProtoLens

datadata StreamingType
#
Instances6Bounded, Enum, Eq, Ord, Read, Show
classclass HasField s (x :: Symbol) a | s x -> a where
#

A type class for lens fields.

The instance HasField s x a can be understood as "s has a field named x of type a".

Methods

Instances490HasField, …
classclass FieldDefault value where
#

A proto3 field type with an implicit default value.

This is distinct from, say, Data.Default to avoid orphan instances, and because Bool doesn't necessarily have a good Default instance for general usage.

Methods

Instances32FieldDefault, …
classclass Message msg where
#

Every protocol buffer is an instance of Message. This class enables serialization by providing reflection of all of the fields that may be used by this type.

Methods

  • defMessage :: msg

    A message with all fields set to their default values.

    Satisfies encodeMessage defMessage == "" and decodeMessage "" == Right defMessage.

Instances70Message, …