How declare in a record a member with generic list of records in F# -


i'm stuck in how pass generic list of records around. wanna 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 list of records of type, , pass around serialize json

p.d: more info issue.

i have forgott add main problem. using generics spread vast rest of functions. need tag generic signature, possible more general , say: "i can have kind of records here?"

you need make table type generic too:

type table<'t> = {title:string; data:tabulardata<'t>}  

and because 2 records have same fields, can use cpu.name explicitly creating table cpu values:

{ title = "hi"; data = [| { cpu.name = "test"; load = 1 } |]} 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -