More on F# Units

Another wonderful thing about units in F# is that you can specify conversions.

Consider the following:

[<Measure>]
type s

[<Measure>]
type m

[<Measure>]
type v = m / s

let v1 = 1<m>
let v2 = 1<s> 
let v3 = 1<v>
let V = (v1 / v2) + v3

The sum at the end works because the compiler can convert from v to m/s

This entry was posted in F# and tagged . Bookmark the permalink.

Leave a Reply