cardano-rpc
Safe HaskellNone
LanguageHaskell2010

Cardano.Rpc.Server.Internal.FieldMask

Description

Normal form of google.protobuf.FieldMask paths, ported from addFieldPath and toFieldMask of protobuf Java's FieldMaskTree.

Paths start at the response message. A path may continue through repeated message fields and then applies to each element. Paths that do not resolve are dropped whole. An absent or empty mask, or a * path, selects everything. A mask whose paths all drop selects nothing.

Synopsis

Documentation

type FieldPath = Text Source #

A dot-separated field mask path, as in google.protobuf.FieldMask.paths (e.g. values.cardano).

data FieldMaskTree msg Source #

A field mask resolved against the descriptors of msg.

Constructors

SelectAll

An absent or empty mask, or a * path.

Select PathTree

The paths that resolved. May be empty, which selects nothing.

Instances

Instances details
Eq (FieldMaskTree msg) Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

Show (FieldMaskTree msg) Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

newtype PathTree Source #

Normalised field mask paths. An empty map at a non-root node selects that whole field.

Constructors

PathTree (Map Text PathTree) 

Instances

Instances details
Eq PathTree Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

Show PathTree Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

applyFieldMask Source #

Arguments

:: Message msg 
=> FieldMaskTree msg

Selects the fields to keep

-> msg

The message to trim

-> msg 

Keep only the selected fields and reset the rest to defaults. Required and unknown fields stay.

data FieldFill (m :: Type -> Type) msg Source #

Effects that fill the fields a mask selects; Nothing when it selects none of them. Effects run left to right.

The type, from the outside in:

  • FieldMaskTree msg ->: each fill sees the part of the mask that applies to msg.
  • Maybe: Nothing when the mask selects none of the fill's fields, so runFill never calls its runner (no node session) for an empty selection.
  • Ap m: the effect that obtains the selected values. Ap gives m (Endo msg) the Semigroup that the Monoid of Maybe needs, and runs combined effects left to right.
  • Endo msg: the setters for the selected fields; (<>) composes them and runFill applies them to defMessage.

Instances

Instances details
Applicative m => Monoid (FieldFill m msg) Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

Methods

mempty :: FieldFill m msg Source #

mappend :: FieldFill m msg -> FieldFill m msg -> FieldFill m msg Source #

mconcat :: [FieldFill m msg] -> FieldFill m msg Source #

Applicative m => Semigroup (FieldFill m msg) Source # 
Instance details

Defined in Cardano.Rpc.Server.Internal.FieldMask

Methods

(<>) :: FieldFill m msg -> FieldFill m msg -> FieldFill m msg Source #

sconcat :: NonEmpty (FieldFill m msg) -> FieldFill m msg Source #

stimes :: Integral b => b -> FieldFill m msg -> FieldFill m msg Source #

runFill Source #

Arguments

:: (Applicative n, Message msg) 
=> (forall x. m x -> n x)

Runs the effects, for example in one node session

-> FieldMaskTree msg

Selects the fields to fill

-> FieldFill m msg

Fills the fields

-> n msg 

Run the effects of the fields the mask selects, then trim the message to the mask. When the mask selects no field, the runner is never called.

runFillPure Source #

Arguments

:: Message msg 
=> FieldMaskTree msg

Selects the fields to fill

-> FieldFill Identity msg

Fills the fields

-> msg 

runFill for fills without effects.

fill Source #

Arguments

:: forall (label :: Symbol) msg a m. (HasField msg label a, KnownSymbol label, Message msg, Functor m) 
=> m a

Obtains the value of the field

-> FieldFill m msg 

Fill the field that the lens label names with the result of the action. When the mask does not select the field, the action never runs and its value is never evaluated.

fillSub Source #

Arguments

:: forall (label :: Symbol) msg sub (m :: Type -> Type). (HasField msg label sub, KnownSymbol label, Message msg, Message sub, Applicative m) 
=> FieldFill m sub

Fills the fields of the sub-message

-> FieldFill m msg 

Fill the singular message field that the lens label names from fills of its own fields, against the part of the mask below it.

fillFrom Source #

Arguments

:: forall (m :: Type -> Type) shared msg. Applicative m 
=> shared

The value the fields are read from

-> FieldFill ((->) shared) msg

Reads each field from the value

-> FieldFill m msg 

Fill several fields from one value that is already at hand, reading each field with a function of it. A field the mask does not select never reads it.

isSelected Source #

Arguments

:: forall (label :: Symbol) msg a. (HasField msg label a, KnownSymbol label, Message msg) 
=> FieldMaskTree msg

The mask, rooted at msg

-> Bool 

Whether the mask needs the field that the lens label names: the field or a field below it is selected. A label that names no field is selected only under SelectAll.

lensLabel Source #

Arguments

:: Text

The proto name of the field

-> Text 

The label proto-lens gives the lenses of a proto field, for example ledger_tip to ledgerTip or plutus_v1 to plutusV1.

normalise Source #

Arguments

:: [FieldPath]

Dotted field mask paths

-> PathTree 

Build a tree from dotted paths; a path below another is dropped, in any order. Paths with an empty segment are dropped too (Java keeps some).

resolve Source #

Arguments

:: Message msg 
=> [FieldPath]

Field mask paths, rooted at msg

-> FieldMaskTree msg 

Resolve field mask paths, rooted at msg, against its proto descriptors. A path that does not name a field is dropped whole.

subMask Source #

Arguments

:: forall (label :: Symbol) msg sub. (HasField msg label sub, KnownSymbol label, Message msg) 
=> FieldMaskTree msg

The mask, rooted at msg

-> FieldMaskTree sub 

The part of a mask below the singular message field that the lens label names, for building that field on its own.

toPaths Source #

Arguments

:: PathTree

Normalised paths

-> [FieldPath] 

The leaves of the tree as dotted paths, sorted ascending. A tree without children has no paths.