F# has some nice succint argument checking functions that can be used like this:
let foo (bar : string) : string =
if bar = null then
nullArg "bar"
...
I prefer a more prescriptive expression, however, a la Code Contracts:
let foo (bar : string) : string =
Contract.Requires (bar <> null, "bar is null")
...
The code I dream about writing is this, however:
let nonNull (expr : Expr) : unit =
// quotation magic
let foo (bar : string) : string =
nonNull <@ bar @>
...
The question is: can this be expressed in F#; or put another way, is there a working implementation for nonNull in F#?
It doesn't look like it to me but perhaps someone here can verify it.