| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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
- type FieldPath = Text
- data FieldMaskTree msg
- newtype PathTree = PathTree (Map Text PathTree)
- applyFieldMask :: Message msg => FieldMaskTree msg -> msg -> msg
- data FieldFill (m :: Type -> Type) msg
- runFill :: (Applicative n, Message msg) => (forall x. m x -> n x) -> FieldMaskTree msg -> FieldFill m msg -> n msg
- runFillPure :: Message msg => FieldMaskTree msg -> FieldFill Identity msg -> msg
- fill :: forall (label :: Symbol) msg a m. (HasField msg label a, KnownSymbol label, Message msg, Functor m) => m a -> FieldFill m msg
- fillSub :: forall (label :: Symbol) msg sub (m :: Type -> Type). (HasField msg label sub, KnownSymbol label, Message msg, Message sub, Applicative m) => FieldFill m sub -> FieldFill m msg
- fillFrom :: forall (m :: Type -> Type) shared msg. Applicative m => shared -> FieldFill ((->) shared) msg -> FieldFill m msg
- isSelected :: forall (label :: Symbol) msg a. (HasField msg label a, KnownSymbol label, Message msg) => FieldMaskTree msg -> Bool
- lensLabel :: Text -> Text
- normalise :: [FieldPath] -> PathTree
- resolve :: Message msg => [FieldPath] -> FieldMaskTree msg
- subMask :: forall (label :: Symbol) msg sub. (HasField msg label sub, KnownSymbol label, Message msg) => FieldMaskTree msg -> FieldMaskTree sub
- toPaths :: PathTree -> [FieldPath]
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 |
| Select PathTree | The paths that resolved. May be empty, which selects nothing. |
Instances
| Eq (FieldMaskTree msg) Source # | |
Defined in Cardano.Rpc.Server.Internal.FieldMask Methods (==) :: FieldMaskTree msg -> FieldMaskTree msg -> Bool Source # (/=) :: FieldMaskTree msg -> FieldMaskTree msg -> Bool Source # | |
| Show (FieldMaskTree msg) Source # | |
Defined in Cardano.Rpc.Server.Internal.FieldMask | |
Normalised field mask paths. An empty map at a non-root node selects that whole field.
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 tomsg.Maybe:Nothingwhen the mask selects none of the fill's fields, sorunFillnever calls its runner (no node session) for an empty selection.Ap m: the effect that obtains the selected values.Apgivesm (Endo msg)theSemigroupthat theMonoidofMaybeneeds, and runs combined effects left to right.Endo msg: the setters for the selected fields;(<>)composes them andrunFillapplies them todefMessage.
Instances
| Applicative m => Monoid (FieldFill m msg) Source # | |
| Applicative m => Semigroup (FieldFill m msg) 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.
Arguments
| :: Message msg | |
| => FieldMaskTree msg | Selects the fields to fill |
| -> FieldFill Identity msg | Fills the fields |
| -> msg |
runFill for fills without effects.
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.
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.
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.
Arguments
| :: forall (label :: Symbol) msg a. (HasField msg label a, KnownSymbol label, Message msg) | |
| => FieldMaskTree msg | The mask, rooted at |
| -> 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.
The label proto-lens gives the lenses of a proto field, for example
ledger_tip to ledgerTip or plutus_v1 to plutusV1.
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).
Arguments
| :: Message msg | |
| => [FieldPath] | Field mask paths, rooted at |
| -> FieldMaskTree msg |
Resolve field mask paths, rooted at msg, against its proto descriptors.
A path that does not name a field is dropped whole.
Arguments
| :: forall (label :: Symbol) msg sub. (HasField msg label sub, KnownSymbol label, Message msg) | |
| => FieldMaskTree msg | The mask, rooted at |
| -> FieldMaskTree sub |
The part of a mask below the singular message field that the lens label names, for building that field on its own.