In F# integer and floating point values can be associated with units of measure, typically used to indicate lengths, mass, etc. F# units of measure give compile time type safety with no runtime performance penalty!.Below is a playable Silverlight mini-game that applies units of measures in F# to 2D game mechanics.
Keys: Z = Left, X = Right, Space = Thrust
To complete the game you must land your craft on the flat ground (to make it a little easier the speed of landing and the orientation of the craft are not significant.
Note: this is a port of an XNA sample I wrote back in 2008.
Gravity
Use the Measure attribute to define your own measure types :
[<Measure>]
type m
[<Measure>]
type s
module Gravity =
let Earth = 9.8<m/s^2> // Standard Gravity
let Lunar = Earth / 6.0
Code: https://bitbucket.org/ptrelford/lunarlandurz
References: