supply-chain-0.0.0.1: Composable request-response pipelines
Safe HaskellSafe-Inferred
LanguageGHC2021

SupplyChain.Vendor

Description

A vendor responds to requests, makes requests, and performs actions

Synopsis

Type

newtype Vendor (up :: Type -> Type) (down :: Type -> Type) (action :: Type -> Type) #

Makes requests, responds to requests, and performs actions

Constructors

Vendor 

Fields

  • handle :: forall product. down product -> Job up action (Referral up down action product)
     

Connection

(>->) Source #

Arguments

:: Vendor up middle action

Upstream

-> Vendor middle down action

Downstream

-> Vendor up down action 

Connect two vendors; the first interprets requests made by the second

id :: Vendor i i action Source #

The identity for (>->); does nothing at all

Some simple vendors

function :: (forall response. down response -> response) -> Vendor up down action Source #

A simple stateless vendor that responds to each request by applying a pure function

action :: (forall response. down response -> action response) -> Vendor up down action Source #

A simple stateless vendor that responds to each request by applying an effectful function

map :: (forall x. down x -> up x) -> Vendor up down action Source #

A vendor that applies a transformation to each request and then simply forwards it upstream.

absurd :: Vendor up (Const Void) action Source #

Vendor that never responds to any requests

Running

run Source #

Arguments

:: Monad action 
=> Vendor (Const Void) down action

Vendor

-> down product

Request

-> action (Referral (Const Void) down action product) 

Run a vendor in its action context

The vendor must not make requests, so its upstream interface is Const Void.

eval Source #

Arguments

:: Vendor (Const Void) down (Const Void)

Vendor

-> down product

Request

-> Referral (Const Void) down (Const Void) product 

Evaluate a vendor with no context

The vendor must evokes neither request nor actions, so both its upstream and action contexts are Const Void.

eval' Source #

Arguments

:: Vendor (Const Void) down (Const Void)

Vendor

-> down product

Request

-> product 

Evaluate a vendor with no context

The vendor must evokes neither request nor actions, so both its upstream and action contexts are Const Void.

Alteration

alter Source #

Arguments

:: (forall x. Effect up action x -> Job up' action' x)

Transformation applied to each effect that the vendor evokes

-> Vendor up down action 
-> Vendor up' down action' 

alter' Source #

Arguments

:: (forall x. Effect up action x -> Effect up' action' x)

Transformation applied to each effect that the vendor evokes

-> Vendor up down action 
-> Vendor up' down action'