Created
September 4, 2015 10:11
-
-
Save vasily-kirichenko/0806a650c7d808e4eae1 to your computer and use it in GitHub Desktop.
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
[<AutoOpen>] | |
module UoM = | |
// Units of measure for other than integral types | |
let inline (++) (w: ^W when ^W: (static member IsMeasureAbbrev: ^tm * ^t -> unit)) (t: ^t) = (# "" t: ^tm #) | |
let inline (--) (w: ^W when ^W: (static member IsMeasureAbbrev: ^tm * ^t -> unit)) (tm: ^tm) = (# "" tm: ^t #) | |
[<MeasureAnnotatedAbbreviation>] | |
type Guid<[<Measure>] 'm> = Guid | |
[<MeasureAnnotatedAbbreviation>] | |
type string<[<Measure>] 'm> = string | |
[<MeasureAnnotatedAbbreviation>] | |
type bool<[<Measure>] 'm> = bool | |
[<MeasureAnnotatedAbbreviation>] | |
type byte<[<Measure>] 'm> = byte | |
type UoM = UoM | |
with | |
static member IsMeasureAbbrev(_: Guid<'m>, _: Guid) = () | |
static member IsMeasureAbbrev(_: string<'m>, _: string) = () | |
static member IsMeasureAbbrev(_: bool<'m>, _: bool) = () | |
static member IsMeasureAbbrev(_: byte<'m>, _: byte) = () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment