v0.3.0
Add static classes CustomDiffer
and CustomDiffer<T>
with facilities for creating ICustomDiffer
s that add support for specific types.
-
CustomDiffer<T>.Build()
creates a custom differ for typeT
based on a diff function that takes twoT
s as argument, and optionally anIDifferFactory
that can be used to get differs for nested types.type MyRecord = { X: string; Y: string } /// A differ for `MyRecord` that only looks at `X`. let myRecordDiffer = CustomDiffer<MyRecord>.Build(fun differFactory -> let stringDiffer = differFactory.GetDiffer<string>() fun value1 value2 -> stringDiffer.Diff(value1.X, value2.X) )
-
CustomDiffer<T>.Map<U>()
creates a custom differ for typeT
by mapping it to a diffable typeU
.type MyOtherRecord = { X: string; Y: string; Z: string } /// A differ for `MyOtherRecord` that only looks at `X` and `Y`. let myOtherRecordDiffer = CustomDiffer<MyRecord>.Map(fun value -> {| X = value.X; Y = value.Y |})
-
CustomDiffer.Leaf<T>()
creates a custom differ for typeT
that treats it as a leaf value using standard equality, customizing the string output.type Username = Username of string /// A differ that treats `Username` as if it was directly an unwrapped string. let usernameDiffer = CustomDiffer.Leaf(fun (Username x) -> x)
-
CustomDiffer.Combine()
creates a custom differ for multiple types by combining multiple custom differs.let myDiffer = CustomDiffer.Combine [ myRecordDiffer; myOtherRecordDiffer; usernameDiffer ]