pulumi / pulumi-java

Java support for Pulumi
Apache License 2.0
69 stars 21 forks source link

Review Union/Either type design #29

Open t0yv0 opened 2 years ago

t0yv0 commented 2 years ago

Hello!

Issue details

Notes from Pawel (from #1):

- no `Union<T0, T1 ... TN>`, just `Either<L, R>`, but I haven't seen
  it used with 3 or more types, and I've had an implementation ready
  from another project

Affected area/feature

pawelprazak commented 2 years ago

Could we not expose Either to the user? Instead of a foo(Either<String, Enum<T>> we could generate a pair foo(String) and foo(Enum<T>.

https://github.com/pulumi/pulumi-jvm/issues/138#issuecomment-1096887776

If we decide to expose the Either some changes to the API would probably be beneficial, but nothing comes to mind of the top of my head.

pawelprazak commented 2 years ago

I'm thinking about renaming:

t0yv0 commented 2 years ago

We definitely will be unrolling Either from input builders, so the user does not need to generate it as input. We can continue using semi-internally for now for example new InputArgs().something() getter may return Either but the user typically does not use getters on inputs. For outputs we'll need to see if it's even used in output positions, my understanding is it's rare.

In the N3+ case we now use Object in output positions. It may be ok for now.

pawelprazak commented 2 years ago

In the N3+ case we now use Object in output positions

it is possible to nest: Either<A, Either<B, C>> but this will get ugly fast ;)