Skip to content

Rewrite pattern section to introduce failable and failure-free patterns. - #74

Merged
BinderDavid merged 7 commits into
mainfrom
rewrite-pattern-section
Nov 9, 2026
Merged

BinderDavid merged 7 commits into
mainfrom
rewrite-pattern-section

Conversation

@BinderDavid

@BinderDavid BinderDavid commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

This is a slightly bigger rewrite of the section on patterns and pattern matching. In particular, we need a clear and precise definition of failable and failure-free patterns vs refutable and irrefutable patterns in order to specify the desugaring rules for do-notation in terms of MonadFail. I added a few numbered subsections to give more structure to the text. I added a new section on Patterns that is different from the section which explains the semantics of pattern matching.

This also fixes #56 by giving precise definitions of both irrefutable and failure-free patterns.

@BinderDavid BinderDavid added the feature: language report Concerns the language specification in the report label Sep 22, 2026
@BinderDavid BinderDavid changed the title WIP: Rewrite pattern section Rewrite pattern section to introduce failable and failure-free patterns. Oct 6, 2026
@BinderDavid
BinderDavid marked this pull request as ready for review October 6, 2026 16:17
@BinderDavid

Copy link
Copy Markdown
Collaborator Author

This was the original text in the Haskell 1.3 report, with a proto-version of the MonadFail proposal and a definition of failure-free patterns:

failure-free-patterns.pdf

@L0neGamer

Copy link
Copy Markdown
Collaborator

I like what's here so far. I'm wondering what the pattern syntax looks like; is it possible to include a screenshot of the visual changes?

Might be worth adding it to CI so reviewers can just click on the relevant check, but that might be more complicated than it's worth doing.

@BinderDavid

Copy link
Copy Markdown
Collaborator Author

I like what's here so far. I'm wondering what the pattern syntax looks like; is it possible to include a screenshot of the visual changes?

There should be no change to the syntax of patterns, the grammar has just been moved into a different subsection. The main changes are a) editorial by introducing more subsections into a long passage of text, and b) spelling out outcomes of pattern matching, linearity, failability and refutability more explicitly in separate subsections. Failability was missing from the report (it is identical to what the Haskell 1.3 report specified), and necessary for the upcoming specification of do-notation desugaring.

@BinderDavid

Copy link
Copy Markdown
Collaborator Author

@mpilgrem @Superstar64 @L0neGamer @noughtmare @blamario @exaexa @adamgundry @endgame @jmct @gilgamec

I have marked this PR as ready for voting: This PR is necessary for us to fully incorporate the MonadFail proposal, since that proposal requires the definition of failure-free patterns.

@exaexa exaexa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reads OK, vote 👍

Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/03-expressions.typ Resolved

@L0neGamer L0neGamer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending other folks' suggestions, looks good to me!

Comment thread chapters/03-expressions.typ Resolved
@noughtmare

Copy link
Copy Markdown
Collaborator

+1

@adamgundry adamgundry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very minor syntactic suggestion, which you are welcome to ignore if you prefer. Otherwise looks good, thanks!

Comment thread chapters/03-expressions.typ Resolved

@endgame endgame left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voting in favour, but with a few final nits.

Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/03-expressions.typ Resolved
@BinderDavid
BinderDavid force-pushed the rewrite-pattern-section branch from 5d461a2 to 5981519 Compare November 6, 2026 19:11
@BinderDavid
BinderDavid merged commit 8e126b4 into main Nov 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: language report Concerns the language specification in the report process: accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refutable vs. Failable Patterns

9 participants