views:

121

answers:

1

Following on from this question, I still seem to be battling at the frontiers of what is possible, though I don't think that I'm doing anything particularly bleeding edge:

type Vector2d = { X: float<'u>; Y: float<'u> }

Gives me error FS0039: The unit-of-measure parameter 'u' is not defined.

And

type Vector2d = { X: float<_>; Y: float<_> }

Gives me error FS0191: anonymous unit-of-measure variables are not permitted in this declaration.

Is it the case that functions can handle 'generic' units of measure, but types can't?

+2  A: 
type Vector2d<[<Measure>]'u> = { X: float<'u>; Y: float<'u> }

should do the trick

Note: This is correct as of the 1.9.6.2 CTP release but this api is not currently viewed as stable

ShuggyCoUk
f# really screws the syntax highlighting doesn't it :)
ShuggyCoUk
Excellent, thankyou!
Benjol
Any chance of looking at my question 1? http://stackoverflow.com/questions/460766/f-units-of-measure-problems-with-genericity
Benjol
@Benjol: is the answer from Brian not correct? It seems ok based on a quick once over
ShuggyCoUk
My answer might not be correct; apparently generic non-zero values were an unintentional feature of CTP. There may be revisions with units in the next release (as well as a bunch of bug fixes to offer better diagnostics).
Brian
Yeah - the non core stuff should be viewed as a moving target- I should probably add a note to that effect on any post incase it becomes horribly out of date
ShuggyCoUk
@ShaggyCoUk, I just had a vague hope you might be able to solve the problem with the # on my seq - no disrespect to Brian...
Benjol
I'm away from my f# environment (and will be for a week), I'll give it a try when I get back. Are you running the latest CTP release?
ShuggyCoUk