I propose we auto-upcast values when type information is available.
The existing way of approaching this problem in F# is adding clucky upcast keywords.
let a : obj list = [1; 2; 3] // This works
let (^^) : seq<'a> -> seq<'a> -> seq<'a> = Seq.append
let a : int seq = [1; 2; 3] ^^ [4; 5; 6] // This also works
// But this doesn't?
let a : int seq = [1; 2; 3] // error FS0001: This expression was expected to have type 'seq<int>' but here has type ''a list'
Pros and Cons
The advantages of making this adjustment to F# are
- Consistency with other scenarios where upcasting is implicit
- Conciseness
- Convenience
The disadvantage of making this adjustment to F# is the possibility of more inheritance-based code that are against F# philosophy.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions:
#3
#91
#536
#792
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
I propose we auto-upcast values when type information is available.
The existing way of approaching this problem in F# is adding clucky
upcastkeywords.Pros and Cons
The advantages of making this adjustment to F# are
The disadvantage of making this adjustment to F# is the possibility of more inheritance-based code that are against F# philosophy.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions:
#3
#91
#536
#792
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply: