Snippets tagged units of measure

  • General power function with units

    The snippet demonstrates how to write a general power function that has correct type involving units-of-measure. The function uses numbers represented using types. The snippet is mainly an example of what can be done (not recommended for the real world).

    5 people like this

    Posted: 6 years ago by Tomas Petricek

  • Using units of measure for safe array access

    A typical problem when working with arrays and indices is that it's easy to access an array with the wrong index. Units of measure in F# can be applied to integers, which makes it possible to abuse them to prevent this kind of error.

    7 people like this

    Posted: 5 years ago by Johann Deneux

  • Improved Generic Units of Measure

    Improved version of http://fssnip.net/pm/title/Extending-units-of-measure-to-arbitrary-types that adopts the "type class" approach and sheds requirement for passing the witness type when tag/untagging UoM values.

    3 people like this

    Posted: 6 months ago by Eirik Tsarpalis