Created
July 18, 2015 09:41
-
-
Save dsyme/b80086ce5c5a0dc1a9f7 to your computer and use it in GitHub Desktop.
type with optional unit of measure annotation and conversion functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//custom type | |
type SomeType(v) = member x.V = v | |
[<AutoOpen>] | |
module Aux1 = | |
//custom type that can carry measure | |
[<MeasureAnnotatedAbbreviation>] | |
type SomeType<[<Measure>] 'm>(v) = | |
member x.V = v | |
[<AutoOpen>] | |
module Aux2 = | |
//module with conversion functions for custom type | |
module SomeType = | |
let inline WithMeasure (x : SomeType) : SomeType<'m> = SomeType<_>(x.V) | |
let inline WithoutMeasure (x : SomeType<'m>) : SomeType = SomeType(x.V) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment