Some of your code was smote by the HTML gods, and I can't decipher what your original code was.

See [link:cs.hubfs.net] for advice on formatting code, and repost.

By on 10/3/2008 4:54 PM ()

hi all,

one of the coolest features of F# is the support for units of measures. While I am excited about it, I found that it is very hard to get things to compile with them.

Right now I have the following problem.

The following code compiles great.

1
2
3
4
5
6
7
8
type Vec2 <[<Measure>] 'm> = 
    struct 
        val x: float 
        val y: float 

        new(xx, yy) = { x = xx; y = yy; } 
        static member (+) (a: Vec2, b: Vec2) = Vec2(a.x+b.x,a.y+b.y) 
    end 

but if I add the following line

1
static member (*) (a: Vec2, b: Vec2) = Vec2(a.x*b.x,a.y*b.y) 

nothing works anymore since the compiler says

1
2
3
warning FS0064: This construct causes code to be less generic than indicated by the type annotations. The unit-of-measure variable 'm has been constrained to be measure ''m1 'm2'. 

error FS0191: This code is less generic than required by its annotations because the explicit type variable 'm' could not be generalized. It was constrained to be ''m1 'm2'. 

Does anybody have any idea how to proceed?

Thanks

x

By on 10/4/2008 2:23 AM ()

Ok it got mangled again on brackets even if the preview worked great. Wow this is frustrating, especially in a language forum! Ok I'll try one more time and substitute curly parens for brackets.

-----------------

hi all,

one of the coolest features of F# is the support for units of measures. While I am excited about it, I found that it is very hard to get things to compile with them.

Right now I have the following problem.

The following code compiles great.

1
2
3
4
5
6
7
8
type Vec2<{<Measure>} 'm> = 
    struct 
        val x: float 
        val y: float 

        new(xx, yy) = { x = xx; y = yy; } 
        static member (+) (a: Vec2, b: Vec2) = Vec2(a.x+b.x,a.y+b.y) 
    end 

but if I add the following line

1
static member (*) (a: Vec2, b: Vec2) = Vec2(a.x*b.x,a.y*b.y) 

nothing works anymore since the compiler says

1
2
3
warning FS0064: This construct causes code to be less generic than indicated by the type annotations. The unit-of-measure variable 'm has been constrained to be measure ''m1 'm2'. 

error FS0191: This code is less generic than required by its annotations because the explicit type variable 'm' could not be generalized. It was constrained to be ''m1 'm2'. 

Does anybody have any idea how to proceed?

Thanks

x

By on 10/4/2008 2:27 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper