dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
908 stars 211 forks source link

No documentation for accessing nested unions #2523

Closed scarf005 closed 1 year ago

scarf005 commented 1 year ago
let CD
    : Type
    = < C | D >

let Flat
    : Type
    = < A : Text | CD : < C | D > >

let a
    : Flat
    = Flat.A "A"

let c
    : Flat
    = Flat.CD CD.C

let d
    : Flat
    = Flat.CD.C
      ~~~~~~~~~ Error: Not a record or a union

let e
    : Flat
    = Flat.CD <C | D>.C

in  { a, c, d, e }

I'm very lost in how to access C inside Flat. I've read through language tour and searched documentation but none of the articles mention how to access nested union.

Gabriella439 commented 1 year ago

There isn't a way to do what you want for expression d. You have do something like you already did in expressions c or e

scarf005 commented 1 year ago

thanks for the clarification. however, it may be hard for beginners to come up with solution c or e. therefore, i'm interested in adding examples for nested unions. should i add the guide for all of these four?

docs.dhall-lang.org/references/Built-in-types.html?highlight=union docs.dhall-lang.org/discussions/Core-language-features.html?highlight=union docs.dhall-lang.org/howtos/Cheatsheet.html?highlight=union docs.dhall-lang.org/tutorials/Language-Tour.html?highlight=union

Gabriella439 commented 1 year ago

I think it would only make sense to mention this in the language tour

scarf005 commented 1 year ago

alright. I'll open a PR shortly after. would there be anything else i should consider?