Description
This seems to more be an F# bug related to a unification error with F# anonymous record types (possibly a dotnet restriction?).
Repro steps
[{|id=5; name ="hello"|}]|> Util.TableExpected behavior
Table output
Actual behavior
Error message:
Type constraint mismatch. The type
'{|id : int ; name : string|} list'
is not compatible with type
'seq<{|id : int ; name : string|}>'
Known workarounds
Define it within a module:
openSystemmoduleMUtil =letRow(columns:seq<Reflection.PropertyInfo>)(item:'A)=
columns
|> Seq.map (fun p -> p.GetValue(item))|> Seq.map Convert.ToString
|> Seq.toArray
letTable(items:seq<'A>,propertyNames:seq<string>option)=letproperties=if propertyNames.IsSome then
typeof<'A>.GetProperties()|> Seq.filter (fun x ->(propertyNames.Value |> Seq.exists (fun y -> x.Name = y)))|> Seq.toArray
else
typeof<'A>.GetProperties(){ Columns = properties |> Array.map (fun x -> x.Name);
Rows = items |> Seq.map (Test.MyRow properties)|> Seq.toArray
}letDefaultTable items = Table (items, None)Then call:
[{|id=5; name ="hello"|}]|> MUtil.DefaultTableRelated information
- Operating system: Ubuntu
- Branch: Master
- CoreCLR
Description
This seems to more be an F# bug related to a unification error with F# anonymous record types (possibly a dotnet restriction?).
Repro steps
Expected behavior
Table output
Actual behavior
Error message:
Known workarounds
Define it within a module:
Then call:
Related information