[commit: ghc] master: Doc improvement for ApplicativeDo (d396996)
git at git.haskell.org
git at git.haskell.org
Tue Apr 26 14:58:14 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d396996298939f647c22b547bc01f1b00e6e2fd9/ghc
>---------------------------------------------------------------
commit d396996298939f647c22b547bc01f1b00e6e2fd9
Author: Simon Marlow <marlowsd at gmail.com>
Date: Fri Apr 15 16:24:59 2016 -0700
Doc improvement for ApplicativeDo
Make it clearer that the final statement should be exactly
"(return|pure) E".
>---------------------------------------------------------------
d396996298939f647c22b547bc01f1b00e6e2fd9
docs/users_guide/glasgow_exts.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index b88cf44..ef66140 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -943,6 +943,11 @@ then the expression will only require ``Applicative``. Otherwise, the expression
will require ``Monad``. The block may return a pure expression ``E`` depending
upon the results ``p1...pn`` with either ``return`` or ``pure``.
+Note: the final statement really must be of the form ``return E`` or
+``pure E``, otherwise you get a ``Monad`` constraint. In particular,
+``return $ E`` is not of the form ``return E``, and will therefore
+incur a ``Monad`` constraint.
+
When the statements of a ``do`` expression have dependencies between
them, and ``ApplicativeDo`` cannot infer an ``Applicative`` type, it
uses a heuristic algorithm to try to use ``<*>`` as much as possible.
More information about the ghc-commits
mailing list