2

Why following code gives me "This code is not sufficiently generic" error?

type Vector2D<'a when 'a : (static member (+) : 'a * 'a -> 'a)  > =
   struct 
      val X: 'a
      val Y: 'a
      new(x: 'a, y: 'a) = {
        X = x; 
        Y = y
        }
   end 
ironic
  • 8,368
  • 7
  • 35
  • 44
  • 1
    I think you can use the member constraints only with [statically resolved type parameters](http://msdn.microsoft.com/en-us/library/dd548046.aspx), which cannot be used on types... – Patryk Ćwiek Feb 24 '14 at 15:54
  • @PatrykĆwiek - they're not usually used on types, but they can be; see my answer [here](http://stackoverflow.com/a/5905776/82959). – kvb Feb 25 '14 at 14:38
  • Something, I would consider as an answer here: http://stackoverflow.com/a/22018922/236099 – ironic Feb 25 '14 at 15:38

0 Answers0