I'm stuck in how pass a generic list of records around. I wanna do this:
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
I wanna create any list of records of any type, and pass it around to serialize to json
P.D: More info about the issue.
I have forgott to add the main problem. Using generics it spread vast to the rest of the functions. So I need to tag EVERYTHING with a generic signature, so is possible to be more general and say: "I can have any kind of records here?"
You need to make the
Table
type generic too:And because your two records have the same fields, you can use
Cpu.name
to explicitly say that you are creating a table with CPU values: