When developing an F # application, I have a type that contains a type property Lazy<'T>.
Apparently, one interesting side effect (pardon of puns) of how F # handles syntactic sugar of properties (unlike the C # method) is that getter and setter properties can return / accept different types. (At least Visual Studio doesn't complain when I write code that uses this observation.)
For example, it is beneficial for me to do this:
let lazyValue = lazy 0
member this.Value
with get () =
lazyValue.Value
and set _lazyVal =
lazyValue <- _lazyVal
... such that Value returns intbut accepts only Lazy<int>.
I am interested in theoretical, idiomatic, and practical objections to this. Is this something where the F # shell will lift its nose? Is there any kind of functional programming that this (object-oriented implementation) clearly violates? Is this approach proven to cause problems in large-scale applications? If so, why / how?
source
share