Given:
let ab = ArgumentBlockSettingStore()
let a = ab :> ISettingStore
Is there a way to define a prefix operator (~~) so that
let ab, a = ~~ArgumentBlockSettingStore() : _ * ISettingStore
becomes possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you’re hitting the compiler restrictions that you mentioned in the comment – you can’t write the
~~operator in a fully generic and safe way meaning that it will only allow casting to an interface that the argument implements. You can define an operator that will cast to any other type, but that’s less safe:I used
inline, because the operator is quite simple, but it works the same way with normal operators. This compiles even if you useRandomin the type annotation fordisposable, which is a bit unfortunate.