f# - Generic class with a measure constraint -


How do I create a generic class in F #, with that type of barrier that type is a measure?

I have tried to do this but A2 and B2 do not produce errors:

  Open Microsoft. FSHRP.data Unit system SI. Type of unit names Vector 2D_A & lt; [& Lt; Remedy & gt;] 'U & gt; X: float & lt; 'U & gt ;, y: float & lt;' U & gt;) = Member this.x = x Member this. Y = y type vector 2D_ B & lt; 'T, [& lt; Remedy & gt;] 'U & gt; (X: T, Y: 't) = Member this.x = x Member this. Y = y type vector2d_C & lt; ' T & gt; (X: 't, y:' t) = member this.x = x member this.Y = y move a1 = vector2d_y (1.0> lt; m>, 2.0 & lt; m & gt;) B1 = Vector 2D_A (1.0> l & gt; 2.0 & lt; m & gt;) C1 = Vector 2 DC (1.0 «met & gt ;, 2.0 & lt; m & gt; A2 = Vector2D_A (1.0, 2.0) // should generate an error, B2 = Vector 2D_A (1.0, 2.0) // should generate an error c2 = Vector2D_C (1.0, 2.0)   < P> I want to define one of these three instances (but they do not compile):  

1)

  Type vector2D_B < 't, [& lt; Remedy & gt;] 'u & gt; (X: 't & lt;' u & gt;, y: 't & lt;' u & gt;) = Member this.x = x Member this. Y = y   

2)

  Type vector2D_B   

3)

  type vector 2D_ B & lt; When not 't': & gt; 'T & lt; _ & Gt; (X: 't & lt;' u & gt;, y: 't & lt;' u & gt;) = Member this.x = x Member this. Y = y    

write 't equals' t & lt; 1 & gt; - Where & lt; 1 & gt; Represents the unit of measure for the dimensionless values, which is inherently applied when no other unit of measurement is clearly provided.

As a result, you can not force the compiler to generate an error message while clearly providing a unit of measurement, when you do so that you provide a unit of measurement for dimensionless values We do.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -