Skip to content

Add keyword for alternatives in a match construct #579

Open
@wenkokke

Description

@wenkokke

edit @pokey:

As discussed in #579 (comment), we'd like to proceed as follows:

Original

There currently is no keyword for selecting alternatives in a match construct. Examples of match constructs are:

  • Python
    match x:
    case Alt1: exp1case AltN: expN
  • Haskell
    f = case x of
      Alt1 -> exp1
      
      AltN -> expN
    or
    f Alt1 = exp1
    
    f AltN = expN

We probably want three keywords:

  • matched to select the value matched on, i.e., x;
  • <ordinal> pattern to select the i’th pattern, i.e., Alt1 to AltN above; and
  • <ordinal> case to select the i’th case, i.e., exp1 to expN above.

Unmodified pattern and case should probably to the scopes relative to the named mark or cursor, i.e., pattern refers to Alt1 if the mark or cursor is in either Alt1 or exp1, and similarly for case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions