Skip to content

add Applicative and MonadFail to monad hierarchy - #79

Open
exaexa wants to merge 35 commits into
mainfrom
mk-applicative
Open

exaexa wants to merge 35 commits into
mainfrom
mk-applicative

Conversation

@exaexa

@exaexa exaexa commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

This should address and fix #8 .

I'd welcome if someone could check the applicative and monad laws and the wording of the applicative class description (partially taken from current haddock).

UPDATED (end of Oct): As the main leftover, this does not fix the do-notation desugaring in Chapter 3, which depends on #74. There's a separate issue as a reminder to fix that later in #101.

UPDATED (Nov 9): This is now rebased over #74 and the box with do translation is fixed (closing #101 along the way).


NOTE: I'll rebase to fix the conflict in the preface once this is finalized and voted -- for git there's always going to be a +/+ conflict reappearing each time another PR gets merged, rebasing everytime would give O(n²) effort with little actual value.

@exaexa
exaexa marked this pull request as draft October 3, 2026 14:45
Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/06-predefined-types.typ Resolved
@L0neGamer

Copy link
Copy Markdown
Collaborator

I think this needs to update the stdlib as well

@exaexa

exaexa commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

@L0neGamer operators should be added now. Following the common, we now also have <$ and <$> :)

The stdlib is coming a bit later.

@L0neGamer

Copy link
Copy Markdown
Collaborator

I noticed you didn't include <$ in the prelude exports, is that intentional?

@exaexa

exaexa commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author

I noticed you didn't include <$ in the prelude exports, is that intentional?

yeah, no. Thanks. Fixed. :D

@exaexa
exaexa changed the base branch from main to split-haskell-typeclass-figure October 3, 2026 21:25
@exaexa
exaexa changed the base branch from split-haskell-typeclass-figure to main October 20, 2026 08:04
@exaexa exaexa added feature: standard libraries Concerns the Haskell 2010 standard libraries feature: language report Concerns the language specification in the report labels Oct 20, 2026
@exaexa
exaexa marked this pull request as ready for review October 20, 2026 08:15
@exaexa
exaexa requested a review from L0neGamer October 20, 2026 08:20
@exaexa

exaexa commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

@BinderDavid once this is checked by another pair of eyes, I think this can go to voting as well (it's sitting here essentially unchanged since Oct 3rd, and there's other work depending on this, mainly the traversable fun)

@exaexa
exaexa added this pull request to stack #98 October 20, 2026 09:49
@BinderDavid

Copy link
Copy Markdown
Collaborator

Just to make sure: This does not fix #8 completely because the MonadFail proposal also entails that the desugaring of do-notation has to be changed. But it is not necessary to do everything in a single PR.

@exaexa

exaexa commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator Author

@BinderDavid reading this https://github.com/quchen/articles/blob/master/monad_fail.md I understand that the desugaring semantics is more related to (un)failable patterns than the actual insertion of the correct implementation of fail, right? If I get it right, it might be easier to glue the desugaring update to the PR that clears out the failability of patterns.

The current PR only has a very mild update in chapter 3 that says where the new fail is from, which I thought could be sufficient for now (ofc unless I'm missing something important, which is likely).

@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.

Does the report specify that Control.Monad should exist? as such, should it require Data.Functor as well?

Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/06-predefined-types.typ Resolved
Comment thread stdlib/src/Control/Applicative.hs Resolved
Comment thread stdlib/src/Control/Monad.hs Resolved
Comment thread stdlib/src/Control/Monad.hs 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.

I am once again being somewhat irritating. If you think my recommendations irrelevant, happy for us to start voting soon hopefully.

Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/09-standard-prelude.typ Resolved
Comment thread chapters/09-standard-prelude.typ Resolved
Comment thread stdlib/src/Control/Applicative.hs Resolved
Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/06-predefined-types.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.

lots of nitpicks but nothing blocking IMO!

Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/06-predefined-types.typ Outdated
Comment on lines +569 to +570
`(<*>)` and `liftA2` apply a function within functors, combining the functor
semantics to form the result.

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.

combining functor semantics doesn't mean much - not sure how much detail the report should go into

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I updated this a bit, decided to keep this notice in some shape, but added a clear note that it's an informal explanation.

If you think it's unnecessary I think we can just as well discard this.

Comment thread chapters/06-predefined-types.typ Resolved
Comment thread chapters/09-standard-prelude.typ Resolved
Comment thread chapters/09-standard-prelude.typ Resolved
Comment thread stdlib/src/Control/Applicative.hs Resolved
Comment thread chapters/03-expressions.typ Resolved
Comment thread chapters/03-expressions.typ Resolved
@BinderDavid

Copy link
Copy Markdown
Collaborator

I think the fixity declarations are missing from the stdlib files.

As a high-level comment: I think we should get rid of section 9 of the report rather sooner than later, or replace it with a stub which doesn't contain any code. It is almost impossible to keep the content of sec 9 in sync with the files in the stdlib directory.

@exaexa

exaexa commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

I think the fixity declarations are missing from the stdlib files.

Oh true, fixed. I was sure I checked that yesterday but lo, I looked exactly at section 9. :D

As a high-level comment: I think we should get rid of section 9 of the report rather sooner than later.

+1 for replacing with a TODO, the double edits are plain out annoying. Later we can typeset the whole stdlib into the PDF as an appendix.

This branch has not been deployed

No deployments
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 feature: standard libraries Concerns the Haskell 2010 standard libraries process: vote-in-progess

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes to the Functor and Monad hierarchy

6 participants