Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- type CallsFed (comp :: Component) = HasAnnotation 'Remote (ShowComponent comp)
- data MakesFederatedCall (comp :: Component) (name :: Symbol)
- data Component
- callsFed :: SolveCallsFed c r a => (c => r) -> a
- class AddAnnotation (loc :: Location) (api :: Symbol) (method :: Symbol) a
- data Location
- type family ShowComponent (x :: Component) = (res :: Symbol) | res -> x where ...
- data Annotation
- class HasFeds a where
- getFedCalls :: Proxy a -> State FedCallFrom [FedCallFrom]
- data FedCallFrom' f = FedCallFrom {}
- newtype Calls = Calls {}
- exposeAnnotations :: ToHasAnnotations x => a -> a
Documentation
type CallsFed (comp :: Component) = HasAnnotation 'Remote (ShowComponent comp) Source #
A typeclass corresponding to calls to federated services. This class has no methods, and exists only to automatically propagate information up to servant.
The only way to discharge this constraint is via callsFed
, which should be
invoked for each federated call when connecting handlers to the server
definition.
data MakesFederatedCall (comp :: Component) (name :: Symbol) Source #
Servant combinator for tracking calls to federated calls. Annotating API
endpoints with MakesFederatedCall
is the only way to eliminate CallsFed
constraints on handlers.
Instances
Instances
Arbitrary Component Source # | |
FromJSON Component Source # | |
ToJSON Component Source # | |
Generic Component Source # | |
Show Component Source # | |
Eq Component Source # | |
FromHttpApiData Component Source # | |
Defined in Wire.API.MakesFederatedCall | |
ToHttpApiData Component Source # | |
Defined in Wire.API.MakesFederatedCall toUrlPiece :: Component -> Text Source # toEncodedUrlPiece :: Component -> Builder Source # toHeader :: Component -> ByteString Source # toQueryParam :: Component -> Text Source # | |
ToSchema Component Source # | |
Defined in Wire.API.MakesFederatedCall | |
type Rep Component Source # | |
Defined in Wire.API.MakesFederatedCall type Rep Component = D1 ('MetaData "Component" "Wire.API.MakesFederatedCall" "wire-api-0.1.0-3915FetN8WgFcCGrbk6Vve" 'False) (C1 ('MetaCons "Brig" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Galley" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Cargohold" 'PrefixI 'False) (U1 :: Type -> Type))) |
callsFed :: SolveCallsFed c r a => (c => r) -> a Source #
Safely discharge a CallsFed
constraint. Intended to be used when
connecting your handler to the server router.
This function should always be called with an argument of
exposeAnnotations
. See the documentation there for more information on
why.
class AddAnnotation (loc :: Location) (api :: Symbol) (method :: Symbol) a Source #
AddAnnotation
constraints are automatically solved by this plugin, but
internally act as "unsolved" constraints, without you needing to propagate
them by hand.
The unsolved constraints can be reintroduced via a ToHasAnnotations
constraint, which will automatically be solved and replaced with
a corresponding HasAnnotation
for every AddAnnotation
in the transitive
closure.
The a
parameter is intentionally ambiguous, existing as a unique skolem to
prevent GHC from caching the results of solving AddAnnotation
. Callers
needn't worry about it.
Instances
Data Location | |
Defined in TransitiveAnns.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Location -> c Location # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Location # toConstr :: Location -> Constr # dataTypeOf :: Location -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Location) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Location) # gmapT :: (forall b. Data b => b -> b) -> Location -> Location # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Location -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Location -> r # gmapQ :: (forall d. Data d => d -> u) -> Location -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Location -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Location -> m Location # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Location -> m Location # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Location -> m Location # | |
Bounded Location | |
Enum Location | |
Show Location | |
Eq Location | |
Ord Location | |
Defined in TransitiveAnns.Types |
type family ShowComponent (x :: Component) = (res :: Symbol) | res -> x where ... Source #
Get a symbol representation of our component.
ShowComponent 'Brig = "brig" | |
ShowComponent 'Galley = "galley" | |
ShowComponent 'Cargohold = "cargohold" |
data Annotation Source #
Instances
class HasFeds a where Source #
getFedCalls :: Proxy a -> State FedCallFrom [FedCallFrom] Source #
Instances
data FedCallFrom' f Source #
Instances
Semigroup (FedCallFrom' Identity) Source # | |
Defined in Wire.API.MakesFederatedCall (<>) :: FedCallFrom' Identity -> FedCallFrom' Identity -> FedCallFrom' Identity # sconcat :: NonEmpty (FedCallFrom' Identity) -> FedCallFrom' Identity # stimes :: Integral b => b -> FedCallFrom' Identity -> FedCallFrom' Identity # | |
Semigroup (FedCallFrom' Maybe) Source # | |
Defined in Wire.API.MakesFederatedCall (<>) :: FedCallFrom' Maybe -> FedCallFrom' Maybe -> FedCallFrom' Maybe # sconcat :: NonEmpty (FedCallFrom' Maybe) -> FedCallFrom' Maybe # stimes :: Integral b => b -> FedCallFrom' Maybe -> FedCallFrom' Maybe # | |
Show (FedCallFrom' Identity) Source # | |
Defined in Wire.API.MakesFederatedCall | |
Show (FedCallFrom' Maybe) Source # | |
Defined in Wire.API.MakesFederatedCall |
exposeAnnotations :: ToHasAnnotations x => a -> a Source #
This function exists only to provide a convenient place for the
transitive-anns
plugin to solve the ToHasAnnotations
constraint. This is
highly magical and warrants a note.
The call
will expand to exposeAnnotations
(some expr here)some expr
here
, additionally generating wanted HasAnnotation
constraints for every
AddAnnotation
constraint in the _transitive call closure_ of some expr
here
.
The use case is always going to be
,
where callsFed
(exposeAnnotations
expr)exposeAnnotations
re-introduces all of the constraints we've been
squirreling away, and callsFed
is responsible for discharging them. It
would be very desirable to combine these into one call, but the semantics of
solving ToHasAnnotations
attaches the wanted calls to the same place as
the call itself, which means the wanteds appear just after our opportunity
to solve them via callsFed
. This is likely not a hard limitation.
The x
parameter here is intentionally ambiguous, existing as a unique
skolem to prevent GHC from caching the results of solving
ToHasAnnotations
. Callers needn't worry about it.