I suggest we ...

Extended record with syntax to work with nested properties

let's say we have the following:

type RecordA =
{ A : int
B : string }

type RecordB =
{ A : bool
B : RecordA }

let a = { A = false
B = { A = 2
B = "foo" } }

and want to update that 2 to a 3.
Currently, we need to do this:

let a' = { a with B = { a.B with A = 3 } }

which doesn't scale to more complex types

It would be nice to have something like

let a' = { a with B.A = 3 }

or something similar

It would also be nice to be able to have something similar with DUs:

type DU =
| Case of p1:int * p2:string

let a = Case(1, "foo")
let a' = { a with p1 = 2 }

35 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Gustavo Guerra 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