DataModule
PackageReified.Data
Summary
| Name | Signature | Synopsis |
|---|---|---|
| assoc | Data.assoc name value | Associates an object field name with one exact value. |
| optionalAssoc | Data.optionalAssoc name value | Associates an object field name with Some value, or omits None. |
| data | Data.data fields | Builds an object from ordered field instructions. |
| fields | Data.fields value | Returns exact field instructions from an existing object. |
| number | Data.number token | Constructs a number from one JSON number token, validated identically on .NET and Fable. |
| objectOfMap | Data.objectOfMap | Builds an object from an F# map, ordered by key. |
| objectOfList | Data.objectOfList | Builds an object from ordered name and value pairs. |
| ofMap | Data.ofMap | Builds object-shaped data from a map of scalar values. |
| ofDictionary | Data.ofDictionary | Builds object-shaped data from a .NET dictionary of scalar values. |
| ofNameValues | Data.ofNameValues | Builds object-shaped data from name and value pairs. |
| ofNameValueCollection | Data.ofNameValueCollection | Builds object-shaped data from a .NET name-value collection. |
| ofCliArgs | Data.ofCliArgs | Builds structured data from command-line arguments. |
| ofJsonElement | Data.ofJsonElement | Copies a .NET 8+ System.Text.Json.JsonElement into structured data. |
| ofJsonDocument | Data.ofJsonDocument | Copies a .NET 8+ System.Text.Json.JsonDocument into structured data. |
| ofConfiguration | Data.ofConfiguration | Builds structured data from flattened configuration keys. |
| ofConfigurationPairs | Data.ofConfigurationPairs | Builds structured data from .NET configuration key and value pairs. |
| tryFind | Data.tryFind | Attempts to find a value at a parsed path. |
| lookup | Data.lookup | Finds a value at a parsed path or returns Null. |
| tryFindPath | Data.tryFindPath | Attempts to parse a path and find its value. |
| lookupPath | Data.lookupPath | Parses a path and finds its value or returns Null. |
| tryRedisplay | Data.tryRedisplay | Attempts to render one scalar value for redisplay. |
| redisplay | Data.redisplay | Renders one scalar value for redisplay. |
| tryRedisplayAt | Data.tryRedisplayAt | Attempts to redisplay a scalar at a parsed path. |
| redisplayAt | Data.redisplayAt | Redisplays a scalar at a parsed path. |
| tryRedisplayPath | Data.tryRedisplayPath | Attempts to parse a path and redisplay its scalar. |
| redisplayPath | Data.redisplayPath | Parses a path and redisplays its scalar. |
| tryPatch | Data.tryPatch edits input | Applies immutable edits atomically in declaration order. |
| patch | Data.patch edits input | Applies edits atomically or raises DataPatchException. |
| applyEdit | Data.applyEdit edit input | Applies one prepared edit or raises DataPatchException. |
| set | Data.set path value input | Replaces one value, or adds a missing final object field, and returns the changed tree. |
| replace | Data.replace path value input | Replaces one existing value and returns the changed tree. |
| remove | Data.remove path input | Removes one existing field or list item and returns the changed tree. |
| append | Data.append path value input | Appends one item to an existing list and returns the changed tree. |
| prepend | Data.prepend path value input | Prepends one item to an existing list and returns the changed tree. |
| insert | Data.insert path index value input | Inserts one item at a valid list index and returns the changed tree. |
| rename | Data.rename path name input | Renames one existing object field without moving it and returns the changed tree. |
| update | Data.update path change input | Applies one function to an existing value and returns the changed tree. |
| diff | Data.diff expected actual | Returns all exact structural differences between two values. |
| compare | Data.compare expected actual | Compares complete values and returns every structural difference. |
| tryMatch | Data.tryMatch expectations actual | Checks path-based expectations and accumulates structured mismatches. |
| render | Data.render input | Renders structured data in a compact, human-readable form. |
| renderIndented | Data.renderIndented input | Renders structured data in an indented, human-readable form. |
| tryText | Data.tryText _arg1 | Attempts to extract text from one structured value. |
| tryBool | Data.tryBool _arg1 | Attempts to extract a Boolean from one structured value. |
| tryNumberToken | Data.tryNumberToken _arg1 | Attempts to extract the preserved token from one number value. |
| tryList | Data.tryList _arg1 | Attempts to extract items from one list value. |
| tryObject | Data.tryObject _arg1 | Attempts to extract ordered fields from one object value. |
Associates an object field name with one exact value.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| value | ^a |
Returns
DataField
Verification Examples
Data.assoc "name" "Ada" // one DataFieldAssociates an object field name with
Some value, or omits None.Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| value | ^value option |
Returns
DataField
Verification Examples
Data.optionalAssoc "nickname" (None: string option) // an omitted DataFieldBuilds an object from ordered field instructions.
Parameters
| Name | Type | Description |
|---|---|---|
| fields | DataField list |
Returns
Data
Verification Examples
Data.data [ Data.assoc "name" "Ada" ]
// Data.Object [ "name", Data.Text "Ada" ]Returns exact field instructions from an existing object.
Parameters
| Name | Type | Description |
|---|---|---|
| value | Data |
Returns
DataField list
Verification Examples
Data.fields (Data.data [ Data.assoc "name" "Ada" ])
// one field instruction for nameConstructs a number from one JSON number token, validated identically on .NET and Fable.
Parameters
| Name | Type | Description |
|---|---|---|
| token | string |
Returns
Data
Verification Examples
Data.number "1.2300e+4" // Data.Number "1.2300e+4"Builds an object from an F# map, ordered by key.
Returns
Map<string, Data> -> Data
Builds an object from ordered name and value pairs.
Returns
(string * Data) list -> Data
Builds object-shaped data from a map of scalar values.
Returns
Map<string, string> -> Data
Builds object-shaped data from a .NET dictionary of scalar values.
Returns
IDictionary<string, string> -> Data
Builds object-shaped data from name and value pairs.
Returns
(string * string) seq -> Data
Builds object-shaped data from a .NET name-value collection.
Returns
NameValueCollection -> Data
Builds structured data from command-line arguments.
Returns
string seq -> Data
Copies a .NET 8+
System.Text.Json.JsonElement into structured data.Returns
JsonElement -> Data
Copies a .NET 8+
System.Text.Json.JsonDocument into structured data.Returns
JsonDocument -> Data
Builds structured data from flattened configuration keys.
Returns
(string * string) seq -> Data
Builds structured data from .NET configuration key and value pairs.
Returns
IEnumerable<KeyValuePair<string, string>> -> Data
Attempts to find a value at a parsed path.
Returns
DataPath -> Data -> Data option
Finds a value at a parsed path or returns
Null.Returns
DataPath -> Data -> Data
Attempts to parse a path and find its value.
Returns
string -> Data -> Data option
Parses a path and finds its value or returns
Null.Returns
string -> Data -> Data
Attempts to render one scalar value for redisplay.
Returns
Data -> string option
Attempts to redisplay a scalar at a parsed path.
Returns
DataPath -> Data -> string option
Redisplays a scalar at a parsed path.
Returns
DataPath -> Data -> string
Attempts to parse a path and redisplay its scalar.
Returns
string -> Data -> string option
Parses a path and redisplays its scalar.
Returns
string -> Data -> string
Applies immutable edits atomically in declaration order.
Parameters
| Name | Type | Description |
|---|---|---|
| edits | DataEdit list | |
| input | Data |
Returns
Result<Data, DataPatchFailure list>
Verification Examples
Data.tryPatch [ replace "name" "Grace" ] (data [ "name" => "Ada" ])
// Ok (data [ "name" => "Grace" ])Applies edits atomically or raises
DataPatchException.Parameters
| Name | Type | Description |
|---|---|---|
| edits | DataEdit list | |
| input | Data |
Returns
Data
Verification Examples
Data.data [ Data.assoc "name" "Ada" ]
|> Data.patch [ DataEdit.replace "name" "Grace" ]
// Data.data [ Data.assoc "name" "Grace" ]Applies one prepared edit or raises
DataPatchException.Parameters
| Name | Type | Description |
|---|---|---|
| edit | DataEdit | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.applyEdit (replace "name" "Grace")
// data [ "name" => "Grace" ]Replaces one value, or adds a missing final object field, and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.set "active" true
// data [ "name" => "Ada"; "active" => true ]Replaces one existing value and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.replace "name" "Grace"
// data [ "name" => "Grace" ]Removes one existing field or list item and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada"; "active" => true ] |> Data.remove "active"
// data [ "name" => "Ada" ]Appends one item to an existing list and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "author" ] ] |> Data.append "roles" "admin"
// data [ "roles" => [ "author"; "admin" ] ]Prepends one item to an existing list and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "admin" ] ] |> Data.prepend "roles" "author"
// data [ "roles" => [ "author"; "admin" ] ]Inserts one item at a valid list index and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| index | int | |
| value | ^a | |
| input | Data |
Returns
Data
Verification Examples
data [ "roles" => [ "author" ] ] |> Data.insert "roles" 1 "admin"
// data [ "roles" => [ "author"; "admin" ] ]Renames one existing object field without moving it and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| name | string | |
| input | Data |
Returns
Data
Verification Examples
data [ "name" => "Ada" ] |> Data.rename "name" "displayName"
// data [ "displayName" => "Ada" ]Applies one function to an existing value and returns the changed tree.
Parameters
| Name | Type | Description |
|---|---|---|
| path | string | |
| change | Data -> Data | |
| input | Data |
Returns
Data
Verification Examples
data [ "active" => true ] |> Data.update "active" (fun _ -> Data.Bool false)
// data [ "active" => false ]Returns all exact structural differences between two values.
Parameters
| Name | Type | Description |
|---|---|---|
| expected | Data | |
| actual | Data |
Returns
DataDifference list
Verification Examples
Data.diff (data [ "name" => "Ada" ]) (data [ "name" => "Grace" ])
// one DifferentValue difference at path "name"Compares complete values and returns every structural difference.
Parameters
| Name | Type | Description |
|---|---|---|
| expected | Data | |
| actual | Data |
Returns
Result<unit, DataDifference list>
Verification Examples
Data.compare (data [ "name" => "Ada" ]) (data [ "name" => "Ada" ])
// Ok ()Checks path-based expectations and accumulates structured mismatches.
Parameters
| Name | Type | Description |
|---|---|---|
| expectations | DataExpectation list | |
| actual | Data |
Returns
Result<unit, DataMismatch list>
Verification Examples
Data.tryMatch [ at "name" "Ada" ] (data [ "name" => "Grace" ])
// Error [ mismatch at path "name": expected "Ada", found "Grace" ]Renders structured data in a compact, human-readable form.
Parameters
| Name | Type | Description |
|---|---|---|
| input | Data |
Returns
string
Verification Examples
Data.render (data [ "name" => "Ada"; "active" => true ])
// { name: "Ada", active: true }Renders structured data in an indented, human-readable form.
Parameters
| Name | Type | Description |
|---|---|---|
| input | Data |
Returns
string
Verification Examples
Data.renderIndented (data [ "name" => "Ada" ])
// {
// name: "Ada"
// }Attempts to extract text from one structured value.
Parameters
| Name | Type | Description |
|---|---|---|
| _arg1 | Data |
Returns
string option
Verification Examples
Data.tryText (Data.Text "Ada") // Some "Ada"Attempts to extract a Boolean from one structured value.
Parameters
| Name | Type | Description |
|---|---|---|
| _arg1 | Data |
Returns
bool option
Verification Examples
Data.tryBool (Data.Bool true) // Some trueAttempts to extract the preserved token from one number value.
Parameters
| Name | Type | Description |
|---|---|---|
| _arg1 | Data |
Returns
string option
Verification Examples
Data.tryNumberToken (Data.Number "1e3") // Some "1e3"Attempts to extract items from one list value.
Parameters
| Name | Type | Description |
|---|---|---|
| _arg1 | Data |
Returns
Data list option
Verification Examples
Data.tryList (Data.List []) // Some []