Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cartermp
Created June 14, 2018 22:52
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 cartermp/27fde6de7f7cbd2d348e9c0f8e4dc12e to your computer and use it in GitHub Desktop.
Save cartermp/27fde6de7f7cbd2d348e9c0f8e4dc12e to your computer and use it in GitHub Desktop.
open FSharp.Data.UnitSystems.SI.UnitSymbols
type float<[<Measure>] 'm> with
member a.Bind(f,x) = f x * a
member a.Return(x) = a * sqrt x
member a.Yield(x) = a / x
member a.Combine(b:float<'m1>, c:float<'m2>) = a * b * c
member a.Quote(x) = System.Runtime.Hosting.ApplicationActivator()
member a.Delay(f) = f() * a
member a.Run(f) = Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.EvaluateQuotation f
[<System.Runtime.CompilerServices.Extension>]
type A =
[<System.Runtime.CompilerServices.Extension>]
static member Yield(_:float<S>, b:float<Pa>) = b * 1.0<C>
// Mystery question: Where does the Celsius come from?
let x =
3.14<S> {
yield 2.71<Pa>
yield 2.71<S>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment