Yoga.Om.Layer
- Package
- purescript-yoga-om-layer
- Repository
- rowtype-yoga/purescript-yoga-om-layer
#OmLayer Source
data OmLayer :: Row Type -> Row Type -> Type -> Typedata OmLayer req err a
A layer that requires dependencies (req), may fail with (err), and produces a value (typically Record prov). Each layer has a unique identity used for automatic memoization within a Scope.
Instances
Functor (OmLayer req err)Apply (OmLayer req err)Applicative (OmLayer req err)Bind (OmLayer req err)Monad (OmLayer req err)Parallel (ParOmLayer req err) (OmLayer req err)(IsSymbol sym, Cons sym (OmLayer nextReq nextErr (Record nextProv)) _rest layers, Union accProv accReq provReqOut, Nub provReqOut provReqOut, Union nextReq _nextReqRest provReqOut, Keys nextReq, Keys accReq, Keys accProv, Union accErr nextErr errMergedRaw, Nub errMergedRaw errMerged, Union accErr _e1 errMerged, Union nextErr _e2 errMerged, Union accProv nextProv provMerged, Nub provMerged provMerged, WireLayersRL tail layers accReq errMerged provMerged resReq resErr resProv) => WireLayersRL (Cons sym (OmLayer nextReq nextErr (Record nextProv)) tail) layers accReq accErr accProv resReq resErr resProv(RowToList prov provRL, HasLabel label provRL hasIt, FindProviderMatch hasIt label sym (Cons sym (OmLayer req err (Record prov)) tail) provider) => FindProvider label (Cons sym (OmLayer req err (Record prov)) tail) provider(RowToList req reqRL, FilterScope reqRL filteredReqRL, EmitEdges sym filteredReqRL allLayers edgeDoc, PrintEdgesRL tail allLayers restDoc) => PrintEdgesRL (Cons sym (OmLayer req err (Record prov)) tail) allLayers (Above edgeDoc restDoc)
#ParOmLayer Source
data ParOmLayer :: Row Type -> Row Type -> Type -> Typedata ParOmLayer req err a
Instances
Functor (ParOmLayer req err)Apply (ParOmLayer req err)Applicative (ParOmLayer req err)Parallel (ParOmLayer req err) (OmLayer req err)
#Scope Source
newtype ScopeA first-class representation of resource lifetime and memoization.
Finalizers are registered via acquireRelease and run in reverse order
when the scope is closed. Layers are automatically memoized by identity
within a scope — the same layer value builds only once.
Instances
FilterScope (Cons "scope" Scope tail) tail
#makeScopedLayer Source
makeScopedLayer :: forall req prov err. Om { scope :: Scope | req } err (Record prov) -> (Record prov -> Aff Unit) -> OmLayer (scope :: Scope | req) err (Record prov)Create a scoped layer with acquire/release semantics.
The release function runs when the enclosing scope closes.
The layer requires scope :: Scope in its context.
#bracketLayer Source
bracketLayer :: forall req prov resource err. Om { scope :: Scope | req } err resource -> (resource -> Aff Unit) -> (resource -> Om { scope :: Scope | req } err (Record prov)) -> OmLayer (scope :: Scope | req) err (Record prov)Bracket-style scoped layer: acquire a resource, register its release, then build provisions from it.
#runScopedWith Source
runScopedWith :: forall prov r rl err_ err. RowToList (exception :: Error -> Aff (Record prov) | r) rl => VariantMatchCases rl err_ (Aff (Record prov)) => Union err_ () (exception :: Error | err) => { exception :: Error -> Aff (Record prov) | r } -> OmLayer (scope :: Scope) err (Record prov) -> Aff (Record prov)Like runScoped but accepts error handlers for layers with typed errors.
#withScoped Source
withScoped :: forall prov a. OmLayer (scope :: Scope) () (Record prov) -> (Record prov -> Aff a) -> Aff aBuild a fully-provided scoped layer and pass the provisions to a callback.
A fresh Scope is created and closed when the callback completes,
running all finalizers in reverse order — whether by success, failure,
or interruption.
For layers with typed errors, use withScopedWith.
#withScopedWith Source
withScopedWith :: forall prov a r rl err_ err. RowToList (exception :: Error -> Aff (Record prov) | r) rl => VariantMatchCases rl err_ (Aff (Record prov)) => Union err_ () (exception :: Error | err) => { exception :: Error -> Aff (Record prov) | r } -> OmLayer (scope :: Scope) err (Record prov) -> (Record prov -> Aff a) -> Aff aLike withScoped but accepts error handlers for layers with typed errors.
#combineRequirements Source
combineRequirements :: forall req1 req2 prov1 prov2 err1 err2 provMerged reqMerged reqDeduped errMerged errDeduped _req1 _req2 _err1 _err2. Union req1 req2 reqMerged => Nub reqMerged reqDeduped => Union req1 _req1 reqDeduped => Union req2 _req2 reqDeduped => Union err1 err2 errMerged => Nub errMerged errDeduped => Union err1 _err1 errDeduped => Union err2 _err2 errDeduped => Union prov1 prov2 provMerged => Nub provMerged provMerged => Keys req1 => Keys req2 => OmLayer req1 err1 (Record prov1) -> OmLayer req2 err2 (Record prov2) -> OmLayer reqDeduped errDeduped (Record provMerged)#provide Source
provide :: forall req prov1 prov2 err1 err2 req2 reqOut errMerged errDeduped _req _prov1 _err1 _err2. Union req _req req => Union prov1 _prov1 prov1 => Union err1 err2 errMerged => Nub errMerged errDeduped => Union err1 _err1 errDeduped => Union err2 _err2 errDeduped => Union prov1 req reqOut => Nub reqOut reqOut => Union req2 _prov1 reqOut => Keys req => Keys prov1 => Keys req2 => OmLayer req2 err2 (Record prov2) -> OmLayer req err1 (Record prov1) -> OmLayer req errDeduped (Record prov2)#recovering Source
recovering :: forall req err rest a (handlersRL :: RowList Type) (handlers :: Row Type) (handled :: Row Type). RowToList handlers handlersRL => VariantMatchCases handlersRL handled (Om (Record req) err Boolean) => Union handled rest (exception :: Error | err) => RetryPolicyM (Om (Record req) err) -> (RetryStatus -> Record handlers) -> OmLayer req err a -> OmLayer req err a#repeating Source
repeating :: forall req err a. RetryPolicyM (Om (Record req) err) -> (RetryStatus -> a -> Om (Record req) err Boolean) -> OmLayer req err a -> OmLayer req err a#wireLayers Source
wireLayers :: forall layers rl req err prov. RowToList layers rl => WireLayersRL rl layers (scope :: Scope) () () req err prov => Record layers -> OmLayer req err (Record prov)#wireLayersDebug Source
wireLayersDebug :: forall layers rl req err prov doc. RowToList layers rl => PrintLayersRL rl doc => Warn (Above (Text "") (Above (Text "%%{init: {\"flowchart\": {\"defaultRenderer\": \"elk\"}} }%%") (Above (Text "flowchart LR") doc))) => WireLayersRL rl layers (scope :: Scope) () () req err prov => Record layers -> OmLayer req err (Record prov)#WireLayersRL Source
class WireLayersRL :: RowList Type -> Row Type -> Row Type -> Row Type -> Row Type -> Row Type -> Row Type -> Row Type -> Constraintclass WireLayersRL (rl :: RowList Type) (layers :: Row Type) (accReq :: Row Type) (accErr :: Row Type) (accProv :: Row Type) (resReq :: Row Type) (resErr :: Row Type) (resProv :: Row Type) | rl layers accReq accErr accProv -> resReq resErr resProv where
Members
wireLayersRL :: Proxy rl -> Record layers -> OmLayer accReq accErr (Record accProv) -> OmLayer resReq resErr (Record resProv)
Instances
WireLayersRL Nil layers accReq accErr accProv accReq accErr accProv(IsSymbol sym, Cons sym (OmLayer nextReq nextErr (Record nextProv)) _rest layers, Union accProv accReq provReqOut, Nub provReqOut provReqOut, Union nextReq _nextReqRest provReqOut, Keys nextReq, Keys accReq, Keys accProv, Union accErr nextErr errMergedRaw, Nub errMergedRaw errMerged, Union accErr _e1 errMerged, Union nextErr _e2 errMerged, Union accProv nextProv provMerged, Nub provMerged provMerged, WireLayersRL tail layers accReq errMerged provMerged resReq resErr resProv) => WireLayersRL (Cons sym (OmLayer nextReq nextErr (Record nextProv)) tail) layers accReq accErr accProv resReq resErr resProv
#FilterScope Source
class FilterScope :: RowList Type -> RowList Type -> Constraintclass FilterScope (rl :: RowList Type) (out :: RowList Type) | rl -> out
Remove scope :: Scope from a RowList (it's always present, just noise).
Instances
FilterScope Nil NilFilterScope (Cons "scope" Scope tail) tail(FilterScope tail out) => FilterScope (Cons sym ty tail) (Cons sym ty out)
#FindProvider Source
class FindProvider :: Symbol -> RowList Type -> Symbol -> Constraintclass FindProvider (label :: Symbol) (rl :: RowList Type) (provider :: Symbol) | label rl -> provider
Given a label, find which layer in the RowList provides it.
Instances
(RowToList prov provRL, HasLabel label provRL hasIt, FindProviderMatch hasIt label sym (Cons sym (OmLayer req err (Record prov)) tail) provider) => FindProvider label (Cons sym (OmLayer req err (Record prov)) tail) provider
#FindProviderMatch Source
class FindProviderMatch :: Boolean -> Symbol -> Symbol -> RowList Type -> Symbol -> Constraintclass FindProviderMatch (hasIt :: Boolean) (label :: Symbol) (sym :: Symbol) (rl :: RowList Type) (provider :: Symbol) | hasIt label sym rl -> provider
Dispatch based on whether the current layer has the label.
Instances
FindProviderMatch True label sym rl sym(FindProvider label tail provider) => FindProviderMatch False label sym (Cons sym ty tail) provider
#HasLabel Source
#EmitEdges Source
#PrintLayersRL Source
class PrintLayersRL :: RowList Type -> Doc -> Constraintclass PrintLayersRL (rl :: RowList Type) (doc :: Doc) | rl -> doc
Walk all layers emitting D2 edges.
Instances
PrintLayersRL Nil (Text "")(PrintEdgesRL rl rl doc) => PrintLayersRL rl doc
#PrintEdgesRL Source
class PrintEdgesRL :: RowList Type -> RowList Type -> Doc -> Constraintclass PrintEdgesRL (rl :: RowList Type) (allLayers :: RowList Type) (doc :: Doc) | rl allLayers -> doc
Instances
PrintEdgesRL Nil allLayers (Text "")(RowToList req reqRL, FilterScope reqRL filteredReqRL, EmitEdges sym filteredReqRL allLayers edgeDoc, PrintEdgesRL tail allLayers restDoc) => PrintEdgesRL (Cons sym (OmLayer req err (Record prov)) tail) allLayers (Above edgeDoc restDoc)
#CheckAllProvided Source
class CheckAllProvided :: Row Type -> Row Type -> Constraintclass CheckAllProvided (required :: Row Type) (available :: Row Type)
Check if all required dependencies are provided.
Instances
(RowToList required reqList, RowToList available availList, CheckAllLabelsExist reqList availList required available) => CheckAllProvided required available
#CheckAllLabelsExist Source
class CheckAllLabelsExist :: RowList Type -> RowList Type -> Row Type -> Row Type -> Constraintclass CheckAllLabelsExist (required :: RowList Type) (available :: RowList Type) (requiredRow :: Row Type) (availableRow :: Row Type)
Check that all labels in required RowList exist in available RowList.
Instances
CheckAllLabelsExist Nil available requiredRow availableRow(CheckLabelExists label ty available requiredRow availableRow, CheckAllLabelsExist tail available requiredRow availableRow) => CheckAllLabelsExist (Cons label ty tail) available requiredRow availableRow
#CheckLabelExists Source
class CheckLabelExists :: Symbol -> Type -> RowList Type -> Row Type -> Row Type -> Constraintclass CheckLabelExists (label :: Symbol) (ty :: Type) (available :: RowList Type) (requiredRow :: Row Type) (availableRow :: Row Type)
Check if a single label exists in the available RowList.
Instances
(TypeEquals ty ty') => CheckLabelExists label ty (Cons label ty' tail) requiredRow availableRow(CheckLabelExists label ty tail requiredRow availableRow) => CheckLabelExists label ty (Cons otherLabel otherTy tail) requiredRow availableRow(Fail (Above (Text "Missing required dependency!") (Above (Text "") (Above (Text "The first missing field is: ") (Above (Quote label) (Above (Text "") (Above (Text "The layer requires: ") (Above (Quote requiredRow) (Above (Text "") (Above (Text "But you provided: ") (Quote availableRow))))))))))) => CheckLabelExists label ty Nil requiredRow availableRow
- Modules
- Yoga.
Om. Layer