Skip to content

Commit

Permalink
Merge pull request #20 from mta-solutions/update-to-use-fsharp-plus
Browse files Browse the repository at this point in the history
Use FSharpPlus
  • Loading branch information
devinlyons authored Oct 8, 2024
2 parents dfaedb1 + 98e5c74 commit 111b959
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="[6,)" />
<PackageReference Update="FSharp.Core" Version="[6.0.6,)" />
</ItemGroup>

</Project>
17 changes: 13 additions & 4 deletions samples/FSharp.Data.Validation.Samples/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
"net8.0": {
"FSharp.Core": {
"type": "Direct",
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "fbv1UwJ2LXVcFCt+GGDPu0sIYA5C6gdDvAupDj3iLQF3clRkua/6J33f+FiGQa8P1tEa+zmz3wrjoTnXZ1UiYg=="
"requested": "[6.0.6, )",
"resolved": "6.0.6",
"contentHash": "oSbTFqPtsp+EGkWAHwYIYYHyXLJRnbzVwcmM06kmXNLdWsp3P6XZViPSJJ2qUQS8feNK+nyPA0qtpNZXANGB7w=="
},
"FSharpPlus": {
"type": "Transitive",
"resolved": "1.4.0",
"contentHash": "He6WVVTZpeMQNBlFHniemTSCWITKgwLIgmznNt2kw0U9G/xWSx7USdssGXd2FGmcpk2FlHInYZNwUw848tI0SQ==",
"dependencies": {
"FSharp.Core": "6.0.6"
}
},
"fsharp.data.validation": {
"type": "Project",
"dependencies": {
"FSharp.Core": "[6.0.0, )"
"FSharp.Core": "[6.0.6, )",
"FSharpPlus": "[1.4.0, )"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/GettingStarted/GettingStarted.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="[6,)" />
<PackageReference Update="FSharp.Core" Version="[6.0.6,)" />
</ItemGroup>
</Project>
17 changes: 13 additions & 4 deletions samples/GettingStarted/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
"net8.0": {
"FSharp.Core": {
"type": "Direct",
"requested": "[6.0.0, )",
"resolved": "6.0.0",
"contentHash": "fbv1UwJ2LXVcFCt+GGDPu0sIYA5C6gdDvAupDj3iLQF3clRkua/6J33f+FiGQa8P1tEa+zmz3wrjoTnXZ1UiYg=="
"requested": "[6.0.6, )",
"resolved": "6.0.6",
"contentHash": "oSbTFqPtsp+EGkWAHwYIYYHyXLJRnbzVwcmM06kmXNLdWsp3P6XZViPSJJ2qUQS8feNK+nyPA0qtpNZXANGB7w=="
},
"FSharpPlus": {
"type": "Transitive",
"resolved": "1.4.0",
"contentHash": "He6WVVTZpeMQNBlFHniemTSCWITKgwLIgmznNt2kw0U9G/xWSx7USdssGXd2FGmcpk2FlHInYZNwUw848tI0SQ==",
"dependencies": {
"FSharp.Core": "6.0.6"
}
},
"fsharp.data.validation": {
"type": "Project",
"dependencies": {
"FSharp.Core": "[6.0.0, )"
"FSharp.Core": "[6.0.6, )",
"FSharpPlus": "[1.4.0, )"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="[6.0.1,)" />
<PackageReference Update="FSharp.Core" Version="[6.0.6,)" />
<PackageReference Include="Giraffe" Version="[6,)" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/FSharp.Data.Validation/FSharp.Data.Validation.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="NonEmptyList.fs" />
<Compile Include="Types.fs" />
<Compile Include="ValueCtx.fs" />
<Compile Include="Utilities.fs" />
Expand All @@ -31,6 +30,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="[6,)" />
<PackageReference Update="FSharp.Core" Version="[6.0.6,)" />
<PackageReference Include="FSharpPlus" Version="[1.4.0,)" />
</ItemGroup>
</Project>
252 changes: 0 additions & 252 deletions src/FSharp.Data.Validation/NonEmptyList.fs

This file was deleted.

10 changes: 6 additions & 4 deletions src/FSharp.Data.Validation/Proof.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open System.Text.Json
open System.Text.Json.Serialization

[<JsonConverter(typeof<ValidationFailuresConverterFactory>)>]
type ValidationFailures<'F> =
type ValidationFailures<'F> =
{ Failures: 'F list
Fields: FailureMap<'F> }
and ValidationFailuresConverter<'F>() =
Expand All @@ -23,7 +23,8 @@ and ValidationFailuresConverter<'F>() =
| 0 -> str
| 1 -> str.ToLower()
| _ -> sprintf "%c%s" (Char.ToLowerInvariant(str[0])) (str.Substring(1))
override this.Read(reader: byref<Utf8JsonReader>, typ, opts) = base.Read(&reader, typ, opts)
override this.Read(reader: byref<Utf8JsonReader>, typ, opts) =
JsonSerializer.Deserialize<ValidationFailures<'F>>(&reader, opts)
override this.Write(writer, fs, opts) =
writer.WriteStartObject()

Expand Down Expand Up @@ -70,7 +71,8 @@ and ProofConverter<'F, 'A>() =
| 0 -> str
| 1 -> str.ToLower()
| _ -> sprintf "%c%s" (Char.ToLowerInvariant(str[0])) (str.Substring(1))
override this.Read(reader: byref<Utf8JsonReader>, typ, opts) = base.Read(&reader, typ, opts)
override this.Read(reader: byref<Utf8JsonReader>, typ, opts) =
JsonSerializer.Deserialize<Proof<'F, 'A>>(&reader, opts)
override this.Write(writer, proof, opts) =
match proof with
| Valid a -> JsonSerializer.Serialize(writer, a, opts)
Expand Down Expand Up @@ -109,7 +111,7 @@ module Proof =
match p2 with
| Valid _ -> Invalid (gfs, lfs)
| Invalid (gfs', lfs') -> Invalid (gfs @ gfs', Utilities.mergeFailures lfs lfs')

let toValidationFailures p =
match p with
| Valid a -> None
Expand Down
Loading

0 comments on commit 111b959

Please sign in to comment.