I have a class defined in C#:
public class Foo
{
public string Bar { get; set; }
}
Then I define a record type in F# with a method returning a new object:
type Bar =
{
FooList: Foo list
}
member this.FromBarList(barList: string list) =
let fooListNotNull =
match this.FooList with
| [] -> []
| _ -> this.FooList |> List.filter (fun x -> (List.contains x.Bar barList ) )
{
FooList = fooListNotNull
}
Since the type 'Bar' will be used in C# code, the property FooList can be null, and I'd like to check for it. But I'm getting the error:
The type 'Foo list' does not have 'null' as a proper value
Despite I find this type of matching in docs: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/values/null-values
How can I match null correctly?