I suggest we ...

Optionally relax signatures of -X, sin X, cos X to allow use w.r.t. subtyping

See https://github.com/Microsoft/visualfsharp/issues/799

type Base(x : int) =
member self.X = x
static member (~-) (a : Base) = Base(-a.X)
static member (+) (a : Base, b : Base) = Base(a.X + b.X)
static member Cos(a : Base) = Base(2*a.X)

type Derived(x : int) =
inherit Base(x)

let a = Base(1)
let minusa = -a // OK
let cosa = cos a // OK
let twoa = a + a // OK
let b = Derived(1)
let minusb = -b // Compile error
let cosb = cos b // Compile error
let twob = b + b // OK

3 votes
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
Don Syme shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...
  • Don Syme commented  ·   ·  Flag as inappropriate

    This is a reasonable request and we should accommodate this somehow. Unfortunately we will likely only be able to do it by having the user open a new module.

F# Language

Feedback and Knowledge Base