Skip to content

Impl Irrefutable Patterns in Match Exprs #6

@eignnx

Description

@eignnx

Currently Ast.Pat (irrefutable patterns) and Ast.RefutPat are totally separate. It would be nice to relate them so that an Ast.Pat can be used wherever an Ast.RefutPat is expected.

Could this be done using recursion schemes?

Ex:

data Pat r
  = VarPat String
  | TuplePat [r]

data RefutPat r
  = VarRefutPat String
  | VrntRefutPat String [r]
  | IrrefutPat  (Pat r)

Then let and match expressions would become:

data Expr
  ...
  | LetF (Pat (Fix Pat)) r
  ...
  | MatchF r [(RefutPat (Fix RefutPat), Seq r)]
  ...

Hopefully this would simplify pattern matching/destructuring compilation in TastToHir.hs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions