Anonymous Union Types

When I have a record that has a field that is of a union type, how do I access that union type?

-- foo.dhall
let foo : Type = { bar : < A | B | C > }
in { foo }

-- demo.dhall
let f = ./foo.dhall
let demo : f.foo = { bar = ? }
in { demo } 

Basically what would be the value of ? in this example?

You’d have to also export the union type from foo.dhall, doing something like:

let MyUnion : Type = < A | B | C>
let foo : Type = { bar : MyUnion }
in { foo, MyUnion }

A union type that is defined as a field of a record type cannot be retrieved/accessed and you’d only be able to use that union type anonymously if that were the case (e.g. < A | B | C >.A). However, there is an open Dhall issue to permit something like what you want, but that hasn’t been standardized or implemented, yet:

Thank you!

1 Like