talira

CasePaths

Key paths for Swift enum cases

open sourceMITfree

CasePaths extends Swift's key path hierarchy to enum cases: annotate an enum with the @CasePathable macro and you can abstractly extract, embed and modify an enum case's associated value the way key paths work for struct and class properties. It's from Point-Free.

Problems it solves

  • work with enum associated values generically in Swift
  • key path-style access to enum cases in Swift
  • modify an enum case's payload without a switch in Swift

Features

  • key paths for enum cases
  • @CasePathable macro
  • extract, embed and modify associated values