0

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?

Community
  • 1
  • 1
Benjol
  • 63,995
  • 54
  • 186
  • 268

1 Answers1

3
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
  • 36,004
  • 6
  • 77
  • 101
  • f# really screws the syntax highlighting doesn't it :) – ShuggyCoUk Jan 29 '09 at 10:17
  • Any chance of looking at my question 1? http://stackoverflow.com/questions/460766/f-units-of-measure-problems-with-genericity – Benjol Jan 29 '09 at 11:42
  • @Benjol: is the answer from Brian not correct? It seems ok based on a quick once over – ShuggyCoUk Jan 29 '09 at 12:14
  • 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 Jan 29 '09 at 17:40
  • 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 Jan 29 '09 at 17:46
  • @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 Jan 30 '09 at 14:44
  • 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 Jan 31 '09 at 16:51