add isNotNull to FSharp.Core
Using "not (isNull a)" in conditions forces usage of parens or pipe operator and is not optimal readability compared to "a |> isNotNull" or "isNotNull a"
let inline isNotNull a = not (isNull a)
in absence of this function, people often take the shortcut of "a <> null" which according to lint is not optimal.
Declining per my comment below.
F# Language Evolution
Gauthier Segay commented
Daniel, you are right, it was added recently because, I guess, it is useful even in the compiler itself (to replace non optimal comparison operators).
Daniel Robinson commented
Did I miss something? It looks like this was added to FSharp.Core -
Don Syme commented
The design principle here is that we don't add negations of operators in FSharp.Core. For example we don't add ``List.notContains`` or ``map.Doesn'tContainKey``. We just have to write ``not (List.contains x l`` or ``x |> List.contains x |> not``
I think it's best that we don't start making individual exceptions to this rule.
Carl Patenaude Poulin commented
I just do (not << isNull)...
Vasily Kirichenko commented
@Martin because it would cause an unnecessary memory allocation (in case it returns Some)
I don't see why notNull was added. I strongly believe `=` operator should be fixed instead.
Martin Schinz commented
Why not Option.fromNullable and check isNone?