3 ms·
The same can be accomplished in F# for those who want this power in the .net ecosystem type Address = { street : string; city : string option } type Au
by VoiceOfWisdom 11y ago
The same can be accomplished in F# for those who want this power in the .net ecosystem
type Address = { street : string; city : string option }
type Author = { name : string; email : string; address : Address option }
type Article = { title : string; content : string; author : Author option }
let printCity (article : Article) =
article.author
|> Option.bind(fun author -> author.address)
|> Option.bind(fun address -> address.city)
|> Option.iter(fun city -> printfn "%s" city)
- daxfohl 11y agoBetter to do with the maybe workflow from Fsharpx: maybe { let! address = author.address let! city = address.city printfn %s city }