Xamarin.SwiftUI
Xamarin.SwiftUI copied to clipboard
[F#] Add operators for State<T>
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.
Sounds like a good one to start, ! might be contentious as it might be depreciated: https://github.com/fsharp/fslang-suggestions/issues/569
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.
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.