diff options
author | Austin Seipp <austin@well-typed.com> | 2013-09-09 13:40:06 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2013-09-11 19:54:36 -0500 |
commit | 75a9664af1c4e6f87794b49a215adb235b20696d (patch) | |
tree | 1748f512a2bde8c58b1e9c34c22203b0b20541ca /docs | |
parent | b20cf4ecbf244f091f4084c11ae2350d248ce6ef (diff) | |
download | haskell-75a9664af1c4e6f87794b49a215adb235b20696d.tar.gz |
Implement the AMP warning (#8004)
This patch implements a warning when definitions conflict with the
Applicative-Monad Proposal (AMP), described in #8004. Namely, this will
cause a warning iff:
* You have an instance of Monad, but not Applicative
* You have an instance of MonadPlus, but not Alternative
* You locally defined a function named join, <*>, or pure.
In GHC 7.10, these warnings will actually be enforced with superclass
constraints through changes in base, so programs will fail to compile
then.
This warning is enabled by default. Unfortunately, not all of
our upstream libraries have accepted the appropriate patches. So we
temporarily fix ./validate by ignoring the AMP warning.
Dan Rosén made an initial implementation of this change, and the
remaining work was finished off by David Luposchainsky. I finally made
some minor refactorings.
Authored-by: Dan Rosén <danr@chalmers.se>
Authored-by: David Luposchainsky <dluposchainsky@gmail.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/7.8.1-notes.xml | 25 | ||||
-rw-r--r-- | docs/users_guide/flags.xml | 7 | ||||
-rw-r--r-- | docs/users_guide/using.xml | 19 |
3 files changed, 51 insertions, 0 deletions
diff --git a/docs/users_guide/7.8.1-notes.xml b/docs/users_guide/7.8.1-notes.xml index 21f5419a1b..d02c32d337 100644 --- a/docs/users_guide/7.8.1-notes.xml +++ b/docs/users_guide/7.8.1-notes.xml @@ -185,6 +185,31 @@ <replaceable>N</replaceable> modules in parallel. </para> </listitem> + + <listitem> + <para> + GHC now generates warnings when definitions conflict with the + Applicative-Monad Proposal (AMP). + + TODO FIXME: reference. + </para> + + <para> + A warning is emitted if a type is an instance of + <literal>Monad</literal> but not of + <literal>Applicative</literal>, + <literal>MonadPlus</literal> but not + <literal>Alternative</literal>, and when a local + function named <literal>join</literal>, + <literal><*></literal> or <literal>pure</literal> is + defined. + </para> + + <para> + The warnings are enabled by default, and can be controlled + using the new flag <literal>-f[no-]warn-amp</literal>. + </para> + </listitem> </itemizedlist> </sect2> diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index 43f843d6ee..00b632d698 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -1502,6 +1502,13 @@ <entry><option>-fno-warn-warnings-deprecations</option></entry> </row> + <row> + <entry><option>-fwarn-amp</option></entry> + <entry>warn on definitions conflicting with the Applicative-Monad Proposal (AMP)</entry> + <entry>dynamic</entry> + <entry><option>-fno-warn-amp</option></entry> + </row> + </tbody> </tgroup> </informaltable> diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml index f03335862b..c2b4a17eb8 100644 --- a/docs/users_guide/using.xml +++ b/docs/users_guide/using.xml @@ -966,6 +966,7 @@ test.hs:(5,4)-(6,7): program. These are: <option>-fwarn-overlapping-patterns</option>, <option>-fwarn-warnings-deprecations</option>, + <option>-fwarn-amp</option>, <option>-fwarn-deprecated-flags</option>, <option>-fwarn-unrecognised-pragmas</option>, <option>-fwarn-pointless-pragmas</option>, @@ -1130,6 +1131,24 @@ test.hs:(5,4)-(6,7): </varlistentry> <varlistentry> + <term><option>-fwarn-amp</option>:</term> + <listitem> + <indexterm><primary><option>-fwarn-amp</option></primary> + </indexterm> + <indexterm><primary>amp</primary></indexterm> + <indexterm><primary>applicative-monad proposal</primary></indexterm> + <para>Causes a warning to be emitted when a definition + is in conflict with the AMP (Applicative-Monad proosal), + namely: + 1. Instance of Monad without Applicative; + 2. Instance of MonadPlus without Alternative; + 3. Custom definitions of join/pure/<*></para> + + <para>This option is on by default.</para> + </listitem> + </varlistentry> + + <varlistentry> <term><option>-fwarn-deprecated-flags</option>:</term> <listitem> <indexterm><primary><option>-fwarn-deprecated-flags</option></primary> |