GHC: Ticket #10751: Implement Phase 1 of MonadFail Proposal (MFP)http://ghc.haskell.org/trac/ghc/ticket/10751
<p>
See also
</p>
<ul><li><a class="ext-link" href="https://www.reddit.com/r/haskell/comments/3a1o06/monadfail_proposal_mfp/"><span class="icon">​</span>https://www.reddit.com/r/haskell/comments/3a1o06/monadfail_proposal_mfp/</a>
</li></ul><p>
<span class="wikiextras phrase todo">TODO</span> At this point this ticket is mostly a reminder that stuff may need to be done for GHC 7.12
</p>
<p>
David Luposchainsky <a class="ext-link" href="https://mail.haskell.org/pipermail/ghc-devs/2015-August/009664.html"><span class="icon">​</span>says that he plans to work on it</a>.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.pnghttp://ghc.haskell.org/trac/ghc/ticket/10751
Trac 1.2.2simonpjFri, 28 Aug 2015 07:37:30 GMTdescription changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:1
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:1
<ul>
<li><strong>description</strong>
modified (<a href="/trac/ghc/ticket/10751?action=diff&amp;version=1">diff</a>)
</li>
</ul>
TicketsimonpjFri, 28 Aug 2015 07:37:48 GMTdescription changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:2
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:2
<ul>
<li><strong>description</strong>
modified (<a href="/trac/ghc/ticket/10751?action=diff&amp;version=2">diff</a>)
</li>
</ul>
TicketquchenFri, 28 Aug 2015 18:36:50 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:3
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:3
<p>
Current status:
</p>
<ul><li>Warnings are issued for missing MonadFail instances. These warnings are on by default and can be toggled with a flag.
</li><li>The (-&gt;)r Monad doesn't yield the correct error message yet: it displays as "m r" in the "missing MonadFail" message.
</li><li>There is a flag to turn on the actual desugaring. It's turned off by default, but can be used to get a hard error if something's been forgotten.
</li><li>The testsuite has been mostly fixed (not sure whether the failing tests are our fault, didn't check it yet)
</li><li>We have lots of WIP commits that aren't very good versioning practice, so the actual patch will need to be squashed down to a handful of useful ones.
</li></ul>
TicketthoughtpoliceFri, 11 Sep 2015 08:38:26 GMTmilestone changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:4
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:4
<ul>
<li><strong>milestone</strong>
changed from <em>7.12.1</em> to <em>8.0.1</em>
</li>
</ul>
<p>
Milestone renamed
</p>
TicketquchenWed, 16 Sep 2015 23:22:52 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:5
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:5
<p>
Draft submitted to Phab: <a class="ext-link" href="https://phabricator.haskell.org/D1248"><span class="icon">​</span>https://phabricator.haskell.org/D1248</a>
</p>
TickethvrThu, 17 Sep 2015 13:05:33 GMTowner sethttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:6
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:6
<ul>
<li><strong>owner</strong>
set to <em>quchen</em>
</li>
</ul>
TickethvrThu, 17 Sep 2015 13:05:41 GMTstatus changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:7
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:7
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>patch</em>
</li>
</ul>
TickethvrThu, 17 Sep 2015 13:06:19 GMTpriority changed; differential sethttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:8
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:8
<ul>
<li><strong>priority</strong>
changed from <em>normal</em> to <em>highest</em>
</li>
<li><strong>differential</strong>
set to <em>Phab:D1248</em>
</li>
</ul>
TicketgoldfireThu, 17 Sep 2015 18:37:38 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:9
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:9
<p>
Sorry for coming to the party late, but is there an up-to-date proposal I could read here? The link in the original post goes to a reddit page, which has links to an "original propsal" and an "update 1", both of which seem to have open questions, and neither of which are editable.
</p>
<p>
I don't have any objections -- just trying to stay informed. Thanks!
</p>
TicketquchenThu, 17 Sep 2015 18:54:49 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:10
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:10
<p>
Discussion of the initial proposal went pretty dead soon, and there was close to no response for the update, so we left it at that (considering the few suggestions we got and that people actually cared about) and fleshed it out on IRC. We modified the transitional strategy based on what we had a bit, and it's in <a class="ext-link" href="https://github.com/quchen/articles/blob/master/monad_fail.md#transitional-strategy"><span class="icon">​</span>https://github.com/quchen/articles/blob/master/monad_fail.md#transitional-strategy</a>, which is what I'm implementing right now.
</p>
<p>
Objections like the purpose of failure - such exception vs. error state - are orthogonal to the proposal, whose main goal by a huge margin is getting fail out of Monad. We can revisit such issues when MonadFail is established, e.g. by adding a new function to the MonadFail class that is called by the compiler, and one that's supposed to be used by the users explicitly.
</p>
TicketsimonpjThu, 17 Sep 2015 22:07:59 GMTcc changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:11
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:11
<ul>
<li><strong>cc</strong>
<em>core-libraries-committee</em> <em>ekmett</em> added
</li>
</ul>
<p>
Just to be clear, this is a Core Libraries Committee matter, so whatever the proposal is, it should be signed off by them.
</p>
<p>
Simon
</p>
TicketekmettFri, 18 Sep 2015 16:21:48 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:12
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:12
<p>
My sense is that support within the committee or this proposal is very high, based on various discussions.
</p>
<p>
I will however, take a moment to formally poll for objections within the committee just to make absolutely sure before I commit to signing off.
</p>
<p>
That said, would it be possible to move the proposal from a github page to the Haskell Wiki for posterity?
</p>
<p>
That would make it easier to express questions about minor points, e.g. whether <code>ViewPatterns</code>/<code>PatternSynonyms</code> should always be considered failable or if they should only be considered failable if their right hand side is.
</p>
<p>
e.g.
</p>
<pre class="wiki">pattern Foo = ((),())
</pre><p>
is clearly an unfailable pattern.
</p>
<p>
as is
</p>
<pre class="wiki">foo (snd -&gt; x) = ...
</pre><p>
as 'x' is unfailable.
</p>
<p>
These compose for useful patterns like
</p>
<pre class="wiki">pattern Polar x y &lt;- (magnitude &amp;&amp;&amp; phase -&gt; (x,y)) where
Polar x y = mkPolar x y
</pre><p>
Those items there are probably the primary sticking point I have personally, but in broad strokes I personally absolutely adore this proposal.
</p>
TicketquchenFri, 18 Sep 2015 17:11:36 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:13
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:13
<blockquote class="citation">
<p>
would it be possible to move the proposal from a github page to the Haskell Wiki for posterity?
</p>
</blockquote>
<p>
Of course, I should have done that earlier. I'll get to it within a few hours.
</p>
TicketquchenFri, 18 Sep 2015 20:07:38 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:14
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:14
<p>
Wiki entry created: <a class="ext-link" href="https://wiki.haskell.org/MonadFail_Proposal"><span class="icon">​</span>https://wiki.haskell.org/MonadFail_Proposal</a>
</p>
TicketsplSun, 04 Oct 2015 13:27:30 GMTcc changedhttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:15
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:15
<ul>
<li><strong>cc</strong>
<em>spl</em> added
</li>
</ul>
TicketsplMon, 05 Oct 2015 10:28:04 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:16
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:16
<p>
I worked a bit on the wiki proposal.
</p>
<p>
I think it would be good to indicate (1) which <code>MonadFail</code> instances will be created and (2) which types with <code>Monad</code> instances will not have <code>MonadFail</code> instances. Since this change affects a number of important packages, those packages should probably be included.
</p>
<p>
Also, I'm not clear on the conclusion for having <code>Monad</code> vs. <code>Applicative</code> as the superclass constraint on <code>MonadFail</code>. I tried to develop the discussion text on this a bit. Since we're getting <code>ApplicativeDo</code> soon, I think it would be useful to work out whether and how these two features are related. I didn't see anything on <a class="wiki" href="http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo">ApplicativeDo</a> referring to the desugaring of pattern matching.
</p>
TicketHerbert Valerio Riedel <hvr@…>Tue, 03 Nov 2015 21:45:30 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:17
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:17
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/8c80dcc166e4a083086d8b240d84563d0c4c4c50/ghc" title="base: Add new Control.Monad.Fail module (re #10751)
This is based on ...">8c80dcc/ghc</a>:
</p>
<pre class="message">base: Add new Control.Monad.Fail module (re #10751)
This is based on David's initial patch augmented by more extensive
Haddock comments.
This has been broken out of D1248 to reduce its size
by splitting the patch into smaller logical pieces.
On its own, this new module does nothing interesting yet.
Later patches will add support for a different desugaring of
`do`-blocks, at which point the new `MonadFail` class will
become more useful.
Reviewed By: ekmett, austin
Differential Revision: https://phabricator.haskell.org/D1424</pre>
TicketBen Gamari <bgamari.foss@…>Tue, 17 Nov 2015 17:30:07 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:18
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:18
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/233d1312bf15940fca5feca6884f965e7944b555/ghc" title="MonadFail proposal, phase 1
This implements phase 1 of the MonadFail ...">233d131/ghc</a>:
</p>
<pre class="message">MonadFail proposal, phase 1
This implements phase 1 of the MonadFail proposal (MFP, #10751).
- MonadFail warnings are all issued as desired, tunable with two new flags
- GHC was *not* made warning-free with `-fwarn-missing-monadfail-warnings`
(but it's disabled by default right now)
Credits/thanks to
- Franz Thoma, whose help was crucial to implementing this
- My employer TNG Technology Consulting GmbH for partially funding us
for this work
Reviewers: goldfire, austin, #core_libraries_committee, hvr, bgamari, fmthoma
Reviewed By: hvr, bgamari, fmthoma
Subscribers: thomie
Projects: #ghc
Differential Revision: https://phabricator.haskell.org/D1248
GHC Trac Issues: #10751</pre>
TicketbgamariTue, 17 Nov 2015 20:14:20 GMTstatus changed; resolution sethttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:19
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:19
<ul>
<li><strong>status</strong>
changed from <em>patch</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
TickethvrWed, 25 Nov 2015 12:18:39 GMTwikipage sethttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:20
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:20
<ul>
<li><strong>wikipage</strong>
set to <em>prime:Libraries/Proposals/MonadFail</em>
</li>
</ul>
TicketBen Gamari <ben@…>Wed, 25 Nov 2015 23:32:23 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:21
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:21
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/c7a058fb8fa4e9dea55692924b49057d63b2fffd/ghc" title="User's Guide: Add links to MFP wiki page
Test Plan: IIAM
Reviewers: ...">c7a058fb/ghc</a>:
</p>
<pre class="message">User's Guide: Add links to MFP wiki page
Test Plan: IIAM
Reviewers: austin, bgamari, quchen
Reviewed By: bgamari, quchen
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1529
GHC Trac Issues: #10751</pre>
TicketHerbert Valerio Riedel <hvr@…>Fri, 27 Nov 2015 11:38:28 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:22
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:22
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/d25f8535a0178984f29178f983536ab40cc471a8/ghc" title="Update transformers submodule
Most notably this pulls in `MonadFail` ...">d25f8535/ghc</a>:
</p>
<pre class="message">Update transformers submodule
Most notably this pulls in `MonadFail` instances
(see also #10751)
- add MonadFail instance for ContT
- re-order methods for consistency
- Add `MonadFail` instances
- Canonicalise Monad instances
- instance Bifunctor Constant</pre>
TicketHerbert Valerio Riedel <hvr@…>Sun, 24 Jan 2016 20:45:07 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:23
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:23
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/fd6dd41c67f3bd23bbf074357219cfd251eb53d6/ghc" title="Implement `-Wnoncanonical-monadfail-instances` warning
The MonadFail ...">fd6dd41c/ghc</a>:
</p>
<pre class="message">Implement `-Wnoncanonical-monadfail-instances` warning
The MonadFail proposal implemented so far via #10751 only warns about
missing `MonadFail` instances based on existence of failible pattern
matches in `do`-blocks.
However, based on the noncanonical Monad warnings implemented via #11150
we can provide a different mechanism for detecting missing `MonadFail`
instances quite cheaply. That is, by checking for canonical `fail` definitions.
In the case of `Monad`/`MonadFail`, we define the canonical implementation of
`fail` to be such that the soft-deprecated method shall (iff overridden) be
defined in terms of the non-deprecated method. Consequently, in case of
`MonadFail`, the `Monad(fail)` method shall be defined as alias of
the `MonadFail(fail)` method.
This allows us at some distant point in the future to remove `fail` from
the `Monad` class, while having GHC ignore/tolerate such literal canonical
method definitions.
Reviewed By: bgamari, RyanGlScott
Differential Revision: https://phabricator.haskell.org/D1838</pre>
TicketBen Gamari <ben@…>Mon, 25 Jan 2016 15:03:43 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:24
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:24
<p>
In <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/132c20894d102558cc8f3aee5bc289425d0ddb24/ghc" title="Rename -Wmissing-monadfail-instance to plural-form
This warning flag ...">132c2089/ghc</a>:
</p>
<pre class="message">Rename -Wmissing-monadfail-instance to plural-form
This warning flag was recently introduced as part of #10751. However,
it was missed during code-review that almost all existing warning
flags use a plural-form, so for consistency this commit renames
that warning flag to `-Wmissing-monadfail-instances`.
Test Plan: local validate (still running)
Reviewers: quchen, goldfire, austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1842
GHC Trac Issues: #10751</pre>
TicketbgamariMon, 25 Jan 2016 16:04:34 GMThttp://ghc.haskell.org/trac/ghc/ticket/10751#comment:25
http://ghc.haskell.org/trac/ghc/ticket/10751#comment:25
<p>
Renaming merged to <code>ghc-8.0</code>.
</p>
Ticket