Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines a type-level language to describe RPC-like microservices independently of the transport and protocol.
Synopsis
- type Package' = Package Symbol Symbol Symbol (TypeRef Symbol)
- data Package serviceName methodName argName tyRef = Package (Maybe serviceName) [Service serviceName methodName argName tyRef]
- type Service' = Service Symbol Symbol Symbol (TypeRef Symbol)
- data Service serviceName methodName argName tyRef
- type Object = 'Service
- type Union = 'OneOf
- type Method' = Method Symbol Symbol Symbol (TypeRef Symbol)
- data Method serviceName methodName argName tyRef = Method methodName [Argument serviceName argName tyRef] (Return serviceName tyRef)
- type ObjectField = 'Method
- type family LookupService (ss :: [Service snm mnm anm tr]) (s :: snm) :: Service snm mnm anm tr where ...
- type family LookupMethod (s :: [Method snm mnm anm tr]) (m :: mnm) :: Method snm mnm anm tr where ...
- data TypeRef serviceName where
- PrimitiveRef :: Type -> TypeRef serviceName
- ObjectRef :: serviceName -> TypeRef serviceName
- SchemaRef :: Schema typeName fieldName -> typeName -> TypeRef serviceName
- RegistryRef :: Registry -> Type -> Nat -> TypeRef serviceName
- THRef :: Type -> TypeRef serviceName
- ListRef :: TypeRef serviceName -> TypeRef serviceName
- OptionalRef :: TypeRef serviceName -> TypeRef serviceName
- type Argument' = Argument Symbol Symbol (TypeRef Symbol)
- data Argument serviceName argName tyRef where
- data Return serviceName tyRef where
- data TyInfo
- data RpcInfo i
- class ReflectRpcInfo (p :: Package') (s :: Service') (m :: Method') where
- reflectRpcInfo :: Proxy p -> Proxy s -> Proxy m -> RequestHeaders -> i -> RpcInfo i
Documentation
type Package' = Package Symbol Symbol Symbol (TypeRef Symbol) Source #
Packages whose names are given by type-level strings.
type Service' = Service Symbol Symbol Symbol (TypeRef Symbol) Source #
Services whose names are given by type-level strings.
type Method' = Method Symbol Symbol Symbol (TypeRef Symbol) Source #
Methods whose names are given by type-level strings.
data Method serviceName methodName argName tyRef Source #
A method is defined by its name, arguments, and return type.
type ObjectField = 'Method Source #
A field in an object takes some input objects, and returns a value or some other object, in GraphQL lingo.
type family LookupService (ss :: [Service snm mnm anm tr]) (s :: snm) :: Service snm mnm anm tr where ... Source #
Look up a service in a package definition using its name.
LookupService '[] s = TypeError ('Text "could not find method " :<>: 'ShowType s) | |
LookupService ('Service s ms ': ss) s = 'Service s ms | |
LookupService ('OneOf s ms ': ss) s = 'OneOf s ms | |
LookupService (other ': ss) s = LookupService ss s |
type family LookupMethod (s :: [Method snm mnm anm tr]) (m :: mnm) :: Method snm mnm anm tr where ... Source #
Look up a method in a service definition using its name.
LookupMethod '[] m = TypeError ('Text "could not find method " :<>: 'ShowType m) | |
LookupMethod ('Method m args r ': ms) m = 'Method m args r | |
LookupMethod (other ': ms) m = LookupMethod ms m |
data TypeRef serviceName where Source #
Defines a reference to a type, either primitive or coming from the schema.
TypeRef
s are used to define arguments and result types.
PrimitiveRef :: Type -> TypeRef serviceName | A primitive type. |
ObjectRef :: serviceName -> TypeRef serviceName | Chain with another service. |
SchemaRef :: Schema typeName fieldName -> typeName -> TypeRef serviceName | Point to schema. |
RegistryRef :: Registry -> Type -> Nat -> TypeRef serviceName | Registry subject, type to convert to, and preferred serialization version |
THRef :: Type -> TypeRef serviceName | To be used only during TH generation! |
ListRef :: TypeRef serviceName -> TypeRef serviceName | Represents a list of values. |
OptionalRef :: TypeRef serviceName -> TypeRef serviceName | Represents a possibly-missing value. |
Instances
(MonadError ServerError m, handler ~ m ()) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetNothing :: Return snm (TypeRef snm)) m handler Source # | |
Defined in Mu.Server wrapHandler :: Proxy '(chn, m) -> Proxy '[] -> Proxy 'RetNothing -> (forall a. m a -> m a) -> handler -> handler | |
(MonadError ServerError m, ToRef chn ref v, handler ~ (ConduitT v Void m () -> m ())) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetStream ref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, ToRef chn ref v, handler ~ m v) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetSingle ref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, ToRef chn eref e, ToRef chn vref v, handler ~ m (Either e v)) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetThrows eref vref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, FromRef chn ref t, Handles chn args ret m h, handler ~ (ConduitT () t m () -> h)) => Handles (chn :: ServiceChain serviceName) (('ArgStream aname ref :: Argument serviceName anm (TypeRef serviceName)) ': args :: [Argument serviceName anm (TypeRef serviceName)]) (ret :: Return serviceName (TypeRef serviceName)) m handler Source # | |
(FromRef chn ref t, Handles chn args ret m h, handler ~ (t -> h)) => Handles (chn :: ServiceChain serviceName) (('ArgSingle aname ref :: Argument serviceName anm (TypeRef serviceName)) ': args :: [Argument serviceName anm (TypeRef serviceName)]) (ret :: Return serviceName (TypeRef serviceName)) m handler Source # | |
Show (TypeRef s) Source # | |
(KnownMaySymbol pname, ReflectServices ss, ReflectService s, ReflectMethod m) => ReflectRpcInfo ('Package pname ss) s m Source # | |
Defined in Mu.Rpc reflectRpcInfo :: Proxy ('Package pname ss) -> Proxy s -> Proxy m -> RequestHeaders -> i -> RpcInfo i Source # |
type Argument' = Argument Symbol Symbol (TypeRef Symbol) Source #
Arguments whose names are given by type-level strings.
data Argument serviceName argName tyRef where Source #
Defines the way in which arguments are handled.
ArgSingle :: Maybe argName -> tyRef -> Argument serviceName argName tyRef | Use a single value. |
ArgStream :: Maybe argName -> tyRef -> Argument serviceName argName tyRef | Consume a stream of values. |
Instances
(MonadError ServerError m, handler ~ m ()) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetNothing :: Return snm (TypeRef snm)) m handler Source # | |
Defined in Mu.Server wrapHandler :: Proxy '(chn, m) -> Proxy '[] -> Proxy 'RetNothing -> (forall a. m a -> m a) -> handler -> handler | |
(MonadError ServerError m, ToRef chn ref v, handler ~ (ConduitT v Void m () -> m ())) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetStream ref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, ToRef chn ref v, handler ~ m v) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetSingle ref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, ToRef chn eref e, ToRef chn vref v, handler ~ m (Either e v)) => Handles (chn :: ServiceChain snm) ('[] :: [Argument snm anm (TypeRef snm)]) ('RetThrows eref vref :: Return snm (TypeRef snm)) m handler Source # | |
(MonadError ServerError m, FromRef chn ref t, Handles chn args ret m h, handler ~ (ConduitT () t m () -> h)) => Handles (chn :: ServiceChain serviceName) (('ArgStream aname ref :: Argument serviceName anm (TypeRef serviceName)) ': args :: [Argument serviceName anm (TypeRef serviceName)]) (ret :: Return serviceName (TypeRef serviceName)) m handler Source # | |
(FromRef chn ref t, Handles chn args ret m h, handler ~ (t -> h)) => Handles (chn :: ServiceChain serviceName) (('ArgSingle aname ref :: Argument serviceName anm (TypeRef serviceName)) ': args :: [Argument serviceName anm (TypeRef serviceName)]) (ret :: Return serviceName (TypeRef serviceName)) m handler Source # | |
data Return serviceName tyRef where Source #
Defines the different possibilities for returning information from a method.
class ReflectRpcInfo (p :: Package') (s :: Service') (m :: Method') where Source #
reflectRpcInfo :: Proxy p -> Proxy s -> Proxy m -> RequestHeaders -> i -> RpcInfo i Source #
Instances
(KnownMaySymbol pname, ReflectServices ss, ReflectService s, ReflectMethod m) => ReflectRpcInfo ('Package pname ss) s m Source # | |
Defined in Mu.Rpc reflectRpcInfo :: Proxy ('Package pname ss) -> Proxy s -> Proxy m -> RequestHeaders -> i -> RpcInfo i Source # |