rfc:adts

PHP RFC: Algebraic Data Types

  • Version: 0.9
  • Date: 2020-10-04
  • Author: Larry Garfield (larry@garfieldtech.com), Ilija Tovilo (tovilo.ilija@gmail.com)
  • Status: Meta-RFC
  • First Published at: http://wiki.php.net/rfc/adts

Introduction

This is an over-arching description of a multi-step process to add Algebraic Data Types to PHP. That effort is happening over multiple implementation RFCs in order to keep them individually digestible. Algebraic Data Types are a valuable tool in data modeling, and in “making invalid states unrepresentable,” an effective technique for avoiding many classes of bug.

Proposal

This proposal is implemented in stages. Each stage has its own RFC. Consult the list below for details of each. They are listed in approximately the order in which they can and should be implemented, although in some cases the order may be safely reversed.

  • Enumerations - The basic unit enumeration type.
  • Tagged Unions - Associating values with enum cases to create tagged unions.
  • Pattern Matching ''is'' keyword - Pattern matching for objects, enumerations, and similar structures. Mainly to condense conditional logic around the structure of enumerations and value objects.
  • isIdentical() method override (future scope)
  • Advanced pattern matching (future scope)
rfc/adts.txt · Last modified: 2020/12/04 22:33 by crell