liveBook · Manning

Missing value

As explained in F# in Action: A Revised Edition of Get Programming with F#

Missing data is information that is absent, unavailable, or not provided for an expected field or value.

A missing value is expected information that is not available. An e-commerce account needs an email address, but its owner may never provide a home address. Treating both fields as potentially null hides that difference: every access needs a check, and a missed check can cause a runtime error. section 9.1 section 9.1.1

Make optionality visible

type Account = { Email: string; HomeAddress: string option } HomeAddress is explicitly optional; Email is required by the domain. Check incoming data and reject a null email at the application boundary rather than carrying null checks through the F# code. section 9.1 section 9.1.5

open System
 
let optionalName : string option = null |> Option.ofObj   #1
let optionalNameTwo = "Isaac" |> Option.ofObj             #2
let optionalAge = Nullable() |> Option.ofNullable         #3
let optionalAgeTwo = Nullable 123 |> Option.ofNullable    #4

These small conversions turn .NET null references and nullable value types into F# options. Keep options inside F# domain code; convert back when passing values to other .NET code. section 9.1.5

This boundary-first approach avoids mixing options, nulls, and nullable values throughout a domain model. Optional fields remain explicit, while required fields can be validated once on entry. section 9.1.5 section 2.1.4

How F# in Action: A Revised Edition of Get Programming with F# covers it

How deep it goes
Explains null risks and boundary conversions with a short listing; mentions Option.map and Option.bind without detailing their use.
Examples
Uses an account's required email and optional home address, plus conversions from null references and nullable values.
What it assumes
Introduces optionality through familiar account fields; assumes .NET reference and value types only for the interoperability details.
What you can do after
Apply it via F# Option to model optional fields and convert .NET null or nullable inputs at application boundaries.
How it connects
Connects missing values to null, F# Option, Nullable<'T>, Result, exceptions, and .NET interoperability.

Also explained in

Compare how 35 books explain missing value →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of F# in Action: A Revised Edition of Get Programming with F#. The section links point to the parts of the book it draws on.