chkn / Xamarin.SwiftUI

.NET bindings for SwiftUI
MIT License
98 stars 7 forks source link

[F#] Add operators for State<T> #29

Open chkn opened 4 years ago

chkn commented 4 years ago

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

7sharp9 commented 4 years ago

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

chkn commented 4 years ago

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.

7sharp9 commented 4 years ago

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.