Repository F# setup
open Reified
open Reified.Refinements
open Reified.Result
open Reified.Schema.JsonCompare complete data
Use exact comparison when every field and item belongs to the expected result.
open Reified
open Reified.DataDSL
let expected = data [ "name" => "Ada"; "plan" => "pro" ]
let actual = data [ "name" => "Ada"; "plan" => "free"; "extra" => true ]
ReifiedReified.DataDSLConcise opt-in syntax for literals, immutable edits, cases, and matching.
expected: Datadata: DataField list -> DataBuilds an object from ordered field instructions. data [ "name" => "Ada"; "active" => true ] // Data.Object [ "name", Data.Text "Ada"; "active", Data.Bool true ]
(=>): string -> ^value -> DataFieldAssociates a field name with an exact value or recursive data pattern.
actual: DataReturn success or differences
Data.compare returns Ok () when the trees are equal. Otherwise it returns every DataDifference.
Data.compare expected expected
// => Ok ()
Data.compare expected actual
// => Error [
// { Path = DataPath.parse "plan"
// Expected = Some (Data.Text "pro")
// Actual = Some (Data.Text "free")
// Cause = DataDifferenceCause.DifferentValue }
// { Path = DataPath.parse "extra"
// Expected = None
// Actual = Some (Data.Bool true)
// Cause = DataDifferenceCause.Unexpected }
// ]
Reified.DataModulecompare: Data -> Data -> Result<unit,DataDifference list>Compares complete values and returns every structural difference. Data.compare (data [ "name" => "Ada" ]) (data [ "name" => "Ada" ]) // Ok ()
expected: Dataactual: DataReturn the difference list directly
Data.diff expected actual returns the same list without wrapping it in Result.
Data.diff expected expected
// => []
Reified.DataModulediff: Data -> Data -> DataDifference listReturns all exact structural differences between two values. Data.diff (data [ "name" => "Ada" ]) (data [ "name" => "Grace" ]) // one DifferentValue difference at path "name"
expected: DataWhat exact means
Exact comparison observes:
- scalar values and scalar shapes
- number spelling, so
1,1.0, and1e0differ - list length, order, and every item
- object field order, field names, duplicate fields, and every field value
Difference causes are Missing, Unexpected, DifferentValue, DifferentShape, and DifferentFieldName.
Every difference includes a path plus the expected and actual values when present.