Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)


Better to do with the maybe workflow from Fsharpx:

    maybe {
      let! address = author.address
      let! city = address.city
      printfn %s city
    }




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: