Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides typeclasses for describing protobuf service metadata. It is intended to be used by library authors to generating bindings against proto services for specific RPC backends.
- class (KnownSymbol (ServiceName s), KnownSymbol (ServicePackage s), HasAllMethods s (ServiceMethods s)) => Service s where
- type ServiceName s :: Symbol
- type ServicePackage s :: Symbol
- type ServiceMethods s :: [Symbol]
- class HasAllMethods s (ms :: [Symbol])
- class (KnownSymbol m, KnownSymbol (MethodName s m), Service s, Message (MethodInput s m), Message (MethodOutput s m)) => HasMethodImpl s (m :: Symbol) where
- type MethodName s m :: Symbol
- type MethodInput s m :: *
- type MethodOutput s m :: *
- type MethodStreamingType s m :: StreamingType
- type HasMethod s m = (RequireHasMethod s m (ListContains m (ServiceMethods s)), HasMethodImpl s m)
- data StreamingType
Documentation
class (KnownSymbol (ServiceName s), KnownSymbol (ServicePackage s), HasAllMethods s (ServiceMethods s)) => Service s Source #
Metadata describing a protobuf service. The s
parameter is a phantom
type generated by proto-lens.
The ServiceName
and ServicePackage
associated type can be used to
generate RPC endpoint paths.
ServiceMethods
is a promoted list containing every method defined on the
service. As witnessed by the HasAllMethods
superclass constraint here,
this type can be used to discover every instance of HasMethod
available
for the service.
type ServiceName s :: Symbol Source #
type ServicePackage s :: Symbol Source #
type ServiceMethods s :: [Symbol] Source #
class HasAllMethods s (ms :: [Symbol]) Source #
Reifies the fact that there is a HasMethod
instance for every symbol
claimed by the ServiceMethods
associated type.
HasAllMethods k s ([] Symbol) Source # | |
(HasAllMethods k s ms, HasMethodImpl k s m) => HasAllMethods k s ((:) Symbol m ms) Source # | |
class (KnownSymbol m, KnownSymbol (MethodName s m), Service s, Message (MethodInput s m), Message (MethodOutput s m)) => HasMethodImpl s (m :: Symbol) Source #
Metadata describing a service method. The MethodInput
and MethodOutput
type families correspond to the Message
s generated by proto-lens for the
RPC as described in the protobuf.
IsClientStreaming
and IsServerStreaming
can be used to dispatch on
library code which wishes to provide different interfaces depending on the
type of streaming of the method.
Library code should use HasMethod
instead of this class directly whenever
the constraint will be exposed to the end user. HasMethod
provides
substantially friendlier error messages when used incorrectly.
type MethodName s m :: Symbol Source #
type MethodInput s m :: * Source #
type MethodOutput s m :: * Source #
type MethodStreamingType s m :: StreamingType Source #
type HasMethod s m = (RequireHasMethod s m (ListContains m (ServiceMethods s)), HasMethodImpl s m) Source #
Helper constraint that expands to a user-friendly error message when m
isn't actually a method provided by service s
.
data StreamingType Source #
Data type to be used as a promoted type for MethodStreamingType
.