When you map inputs to outputs with a function that can return None, or Some Output, you get an annoying issue of having a list containing Nones, and Some
// Contains both encrypted and un-encrypted files: let listOfFiles:SeqHere are two ways to remedy that:
// Return a decrypted File, or None if the file can't be decrypted. let decryptFile file match file with | isFileDecryptable file -> Some DecryptFile file | _ -> None // decryptedFiles contains Nones, intertwined with some Some DecryptedFiles let decryptedFiles = listOfFiles |> Seq.map decryptFile
// To get a list of only decrypted files you could do: let realDecryptedFiles = decryptedFiles |> Seq.filter Option.isSome |> Seq.map Option.get // However, I prefer the more concise version of: let realDecryptedFiles = decryptedFiles |> Seq.collect Option.toListIf you're an F# guru I'd love to hear your thoughts on this.