Now that the C# 6 is finally going to have this long-anticipated ?. operator, is there similar thing in F#? And I'm not talking about ? operator.
相关问题
- F#: Storing and mapping a list of functions
- Multiplying a list of tuples by a tuple in F#
- Multiplying a string in F#
- F# odd pattern matching issues
- Why doesn't bindingRedirect affect FSharp.Core
相关文章
- FSharp.Data.JsonProvider - Getting json from types
- Signing an F# Assembly (Strong name component)
- Learning F#: What books using other programming la
- fsc.exe is very slow because it tries to access cr
- Extension methods for specific generic types
- F# Object Initialization with a Constructor
- F# Lazy Evaluation vs Non-Lazy
- When to use interfaces, and when to use higher ord
In functional languages, conditional / compositional traversal, especial in nested structures is generally modelled using the notion of lenses which is explained with a succinct example in this SO thread.
In the F# environment, there's Aether; see intro article and guide, which builds on the Lenses support developed and written about by Mauricio Scheffer in FSharpx here.
You can lift your nullable into option first. And then you can use an option computation expression to achieve the same thing.
Idiomatic F# doesn't have null values at all, so what use would it be? In F#, the most common way to model the absence of a value is to use
option
.When I need to interoperate with .NET code that may return
null
, I convert it to an option as soon as possible, using a function like this:As soon as you have your value modelled as an
option
, you can compose it with e.g. Option.map, and that serves the same purpose (but better, and safer) than the proposed C# operator.