Xamarin.SwiftUI icon indicating copy to clipboard operation
Xamarin.SwiftUI copied to clipboard

[F#] Add operators for State<T>

Open chkn opened this issue 5 years ago • 3 comments

From the F# perspective, State<T> is just like a ref cell. We should add an F# type extension for State<T> that provides the ! dereference and := assignment operators for it.

chkn avatar Jun 23 '20 13:06 chkn

Sounds like a good one to start, ! might be contentious as it might be depreciated: https://github.com/fsharp/fslang-suggestions/issues/569

7sharp9 avatar Jun 23 '20 16:06 7sharp9

Oh interesting! Though that conversation looks like it's been ongoing for years, and the last comment is from over a year ago.

Personally, I think the ! could be more readable. For C#, we can define an implicit conversion from State<T> to T, but for F# you'd basically be stuck writing out .Value everywhere without this.

chkn avatar Jun 23 '20 19:06 chkn

Yeah I personally dislike not more than ! as seen in the comments. I'll see about adding it to the F# sample just to see what it looks like. Try and get the C#/F# examples vaguely the same too.

7sharp9 avatar Jun 23 '20 19:06 7sharp9