F # Units, generality issues 2

Following from this question, I still seem to be fighting at the edges of what is possible, although I don't think I am doing anything especially at the edge of the bloodstream:

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

      

Gives error FS0039: The unit parameter u is not defined.

AND

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

      

Gives me error FS0191: Anonymous variable units are not allowed in this declaration.

In this case, functions can handle "common" units, but types cannot?

0


source to share


1 answer


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

      

gotta do the trick



Note. This is true for version 1.9.6.2 of the CTP, but this api is not currently considered stable.

+2


source







All Articles