Generics 如何在记录中声明具有F中记录的通用列表的成员#
我被困在如何传递一个通用的记录列表中。我想这样做:Generics 如何在记录中声明具有F中记录的通用列表的成员#,generics,f#,record,Generics,F#,Record,我被困在如何传递一个通用的记录列表中。我想这样做: type TabularData<'T>= array<'T> type Table = {title:string; data:TabularData<'T>} //This of course not work type Cpu = { name:string; load:int; } type Memory = { name:string; load:int; } //F# not l
type TabularData<'T>= array<'T>
type Table = {title:string; data:TabularData<'T>} //This of course not work
type Cpu =
{ name:string; load:int; }
type Memory =
{ name:string; load:int; }
//F# not let me pass CPU or Memory
类型tablerdata
type Table={title:string;data:tablerdata您还需要将表
类型设置为泛型:
type Table<'T> = {title:string; data:TabularData<'T>}
类型表}?
{ title = "hi"; data = [| { Cpu.name = "test"; load = 1 } |]}