package middleware
Module Middleware.Make2Source
Creates a Middleware module, providing effects with the given two-parameter Monad.
Parameters
Signature
stop x creates a Stop Diverter with the return value x.
val continue :
'next_input ->
('next_output -> ('output, 'm) M.t) ->
('next_input, 'next_output, 'output, 'm) Diverter.tcontinue next_input fn creates a Continue diverter, passing next_input to the subsequent Middleware g. fn is applied to the value returned by g.
type ('input, 'next_input, 'next_output, 'output, 'm) t =
'input ->
('next_input, 'next_output, 'output, 'm) Diverter.tA function which composes with other Middleware functions. Composed Middleware can respond to the return value of Middleware running later. When a Middleware function f runs, it either:
Stops, and returns a resultContinues by allowing the next middleware functiongto run- After
gruns, control returns tof, wherefcan respond tog's result and change its own return value.
terminate ma fb terminates Middleware ma by providing a function fb which does not delegate. In order to turn a Middleware chain into a function, it must be terminated by a non-delegating function using terminate.
val compose :
('ai, 'bi, 'bo, 'ao, 'm) t ->
('bi, 'ci, 'co, 'bo, 'm) t ->
('ai, 'ci, 'co, 'ao, 'm) tcompose ma mb composes two Middleware functions. When run, ma first runs, giving mb the option to continue later on. Note that a composed Middleware still need to be terminated via terminate to be called.