Skip to content

Instantly share code, notes, and snippets.

@drvink
Forked from undeadcat/gist:3916cc75cd3263ff37b8
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drvink/10834244d28f9e426db0 to your computer and use it in GitHub Desktop.
Save drvink/10834244d28f9e426db0 to your computer and use it in GitHub Desktop.
let inline retype (t : ^t) :^tm = (# "" t : ^tm #)
let inline (++) (w : ^W when ^W : (static member IsMeasureAbbrev : ^tm * ^t -> unit)) (t : ^t) = (# "" t : ^tm #)
open System
[<MeasureAnnotatedAbbreviation>]
type Guid<[<Measure>] 'Measure> = Guid
[<MeasureAnnotatedAbbreviation>]
type string<[<Measure>] 'Measure> = string
type UoM =
| UoM
static member IsMeasureAbbrev(_ : Guid<'Measure>, _ : Guid) = ()
static member IsMeasureAbbrev(_ : string<'Measure>, _ : string) = ()
[<Measure>]
type processId
[<Measure>]
type taskId
type Entry =
{ ProcessId : Guid<processId>
TaskId : Guid<taskId> }
let (taskId : Guid<taskId>) = UoM ++ Guid.NewGuid()
let (pid : Guid<processId>) = UoM ++ Guid.NewGuid()
let entry =
{ ProcessId = pid
TaskId = taskId }
[<EntryPoint>]
let main argv =
let (taskId : Guid<taskId>) = UoM ++ Guid.NewGuid()
let (pid : Guid<processId>) = UoM ++ Guid.NewGuid()
let good ={ProcessId = retype (Guid.NewGuid()); TaskId = retype (Guid.NewGuid())}
let evil ={ProcessId = retype (Guid.NewGuid()); TaskId = retype (false)}
printfn "%A" argv
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment