Skip to content

Modelling ADTs: union types vs mixin  #585

@ShahOdin

Description

@ShahOdin

I want to end up generating the following scala code:

saeld trait Foo {
  val internal_id: String
  val external_id: String 
}

object Foo{
  case object Bar extends Foo {
    val internal_id: String = "1"
    val external_id: String = "2"
  }

  case object Baz extends Foo {
    val internal_id: String = "10"
    val external_id: String = "20"
  }
}

as closely as possible. What would be the cleanest/preferred way of achieving this in smithy? Think both union types and mixins would give me something close enough 🤔

ideally, It'd be nice if we can have an enumeratum style Foo.all method generated for us as well. that would return Seq(Bar, Baz)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions