using System;
using System.Collections.Generic;
using System.Linq;
public record Data(DateTime? date);
public class C {
public IEnumerable<Data> M() {
var datum = new []{new Data(DateTime.Now),new Data(null)};
var result = from d in datum orderby d.date select d;
return result;
}
}
I'd like the same to work in F#
open System
type Data = {date: DateTime Nullable }
let datum = [|{date = Nullable DateTime.Now}; {date = Nullable()}|]
let q = query {
for d in datum do
sortBy d.date
select d
}
but it gives:
error FS0001: The type 'Nullable' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface
If it doesn't come as default, is it something that can be extended by overloading SortBy implementation or should be added to FSharp.Core?
I now see sortByNullable below in the code is a separate function and also in the query expr doc, I guess that's the way to do it if it can't be an overload.
The following C# works out of the box
I'd like the same to work in F#
but it gives:
If it doesn't come as default, is it something that can be extended by overloading SortBy implementation or should be added to FSharp.Core?
https://github.com/dotnet/fsharp/blob/830a411cbad94d128fe40cedd2a24a69ccda35a6/src/fsharp/FSharp.Core/Query.fs#L216-L217