I suggest we ...

Record type inference suggestion

Note that if the record {a: int; b: int} is declared last, then type + argument name type inference will not work. Switching the order around resolves the issue. However, this behaviour can be a little mentally jarring.

The lightweight syntax is very useful. It'd be great to strengthen it up.

module Eg1 =
type AB = {a: int; b: int}
type A = {a: int}
type B = {b: int}
let a = {a=1}
let b = {b=2}
let ab = {a=1;b=2}

module Eg2 =
type A = {a: int}
type B = {b: int}
type AB = {a: int; b: int} // <- NB. only the order has changed
let a = {a=1} // fail
let b = {b=2} // fail

// note that example 3 resolves the ambiguity with the dot syntax on the first named field, but that's not the point.

module Eg3 =
type A = {a: int}
type B = {b: int}
type AB = {a: int; b: int}
let a = {A.a=1}
let b = {B.b=2}
let ab = {a=1;b=2}

1 vote
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
Steven Taylor shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

2 comments

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...

F# Language

Feedback and Knowledge Base