Enabling Contributions to the Visual F# IDE Tools(blogs.msdn.com) |
Enabling Contributions to the Visual F# IDE Tools(blogs.msdn.com) |
Note also that this blog post is about accepting contributions to the Visual Studio IDE components for F#, not for the language itself (which has been open source for many years, and has already been accepting contributions from the community for a little while).
I just learned that they could be implemented in C# relatively easily (although maybe not to same extent): http://www.codeproject.com/Articles/413750/Units-of-Measure-...
By being built into the language, units of measure in F# work naturally with type inference (and definitions can be measure-generic), so:
let weirdOperation (x:float<_>) (y:float<_>) = x * x + y * y * y
will be inferred to have type x:float<'u ^ 3> -> y:float<'u ^ 2> -> float<'u ^ 6>I guess, but: source code is still standard C#, it gives you pre-runtime static verification. As far as I understand Roslyn will support this kind of extensibility in a straightforward way. It is still better than unit testing same stuff in my opinion (except for specifying units in comments).
"By being built into the language" - do you mean F# code that uses units of measure wouldn't compile to OCAML (I am talking about simple compilability rather than proper support)?
To your later question, while F# and OCaml share a common core, there's lots of F# code that won't compile as OCaml and vice versa, and units of measure are one such example. The syntax for measure-annotated types is not valid OCaml syntax.