I just updated my prototype tuple to the record. Someday it will become a real class. In the meantime, I want to translate the code as follows:
type Example = int * int let examples = [(1,2); (3,4); (5,6)] let descs = Seq.map (fst >> sprintf "%d") examples
:
type Example = { Field1 : int Field2 : int Description : string } let examples = [{Field1 = 1; Field2 = 2; Description = "foo"} {Field1 = 3; Field2 = 4; Description = "bar"} {Field1 = 5; Field2 = 6; Description = "baz"}] let descs = Seq.map Description examples
The problem is that I was expecting to get a Description : Example -> string function when I declared an example record, but I do not. I joked a bit and tried properties on classes, but that doesn't work either. Am I just missing something in the documentation or will I have to write higher order accessors manually? (This is the workaround I'm using now.)
source share