Skip to content

Proposal: Remove ad-hoc handling of case formatting in the parser #4012

@natefaubion

Description

@natefaubion

Summary

The parser has a couple of ad-hoc cases in the parser that should not be necessary.

-- These special cases handle some idiosynchratic syntax that the current
-- parser allows. Technically the parser allows the rhs of a case branch to be
-- at any level, but this is ambiguous. We allow it in the case of a singleton
-- case, since this is used in the wild.
| 'case' sep(expr, ',') 'of' '\{' sep(binder1, ',') '->' '\}' exprWhere
{ ExprCase () (CaseOf $1 $2 $3 (pure ($5, Unconditional $6 $8))) }
| 'case' sep(expr, ',') 'of' '\{' sep(binder1, ',') '\}' guardedCase
{ ExprCase () (CaseOf $1 $2 $3 (pure ($5, $7))) }

Motivation

I originally added these cases to keep some core modules compiling that use extremely odd formatting for single-branch cases. Normally these would run afoul the offside rule, but the old parser accepted them due to various idiosyncrasies.

https://github.com/purescript/purescript-transformers/blob/42175954755a0fa0fe688579309032a948d919fb/src/Control/Monad/Writer/Trans.purs#L82-L86

Proposal

We should remove these cases in 0.15 and update the core libraries. We can warn in a followup 0.14 release.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions