SE-0479: Method and Initializer Key Paths

Wanted to say thanks for your work on this! Really looking forward to what it will enable in the language.

Also was curious about any consideration for enum support. While I know enums are their own beast and will require their own key paths to fully encapsulate their behavior, I was wondering if the team has considered stopgap partial support considering this earlier pitch alongside this proposal's support for initializers.

For example:

enum Enum {
  case a
  case b(Int)
}

I could see \Enum.Type.a to produce a KeyPath<Enum.Type, Enum> and \Enum.Type.b to produce a KeyPath<Enum.Type, (Int) -> Enum>. And then, whenever the embedding functionality of enums is supported, these could become some form of CaseKeyPaths instead.

16 Likes