diff options
author | Matthias Pall Gissurarson <mpg@mpg.is> | 2020-05-19 22:50:47 +0200 |
---|---|---|
committer | Facundo DomÃnguez <facundo.dominguez@tweag.io> | 2020-06-26 17:12:45 +0000 |
commit | 9ee58f8d900884ac8b721b6b95dbfa6500f39431 (patch) | |
tree | 2025e2f3ef4a92b252059287ea5d84745eec1118 /docs/users_guide/8.12.1-notes.rst | |
parent | a3d69dc6c2134afe239caf4f881ba5542d2c2be0 (diff) | |
download | haskell-9ee58f8d900884ac8b721b6b95dbfa6500f39431.tar.gz |
Implement the proposed -XQualifiedDo extension
Co-authored-by: Facundo DomÃnguez <facundo.dominguez@tweag.io>
QualifiedDo is implemented using the same placeholders for operation names in
the AST that were devised for RebindableSyntax. Whenever the renamer checks
which names to use for do syntax, it first checks if the do block is qualified
(e.g. M.do { stmts }), in which case it searches for qualified names in
the module M.
This allows users to write
{-# LANGUAGE QualifiedDo #-}
import qualified SomeModule as M
f x = M.do -- desugars to:
y <- M.return x -- M.return x M.>>= \y ->
M.return y -- M.return y M.>>
M.return y -- M.return y
See Note [QualifiedDo] and the users' guide for more details.
Issue #18214
Proposal:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst
Since we change the constructors `ITdo` and `ITmdo` to carry the new module
name, we need to bump the haddock submodule to account or the new shape of
these constructors.
Diffstat (limited to 'docs/users_guide/8.12.1-notes.rst')
-rw-r--r-- | docs/users_guide/8.12.1-notes.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/users_guide/8.12.1-notes.rst b/docs/users_guide/8.12.1-notes.rst index 1bf9464db4..deb29310ff 100644 --- a/docs/users_guide/8.12.1-notes.rst +++ b/docs/users_guide/8.12.1-notes.rst @@ -150,6 +150,20 @@ Language data U a where MkU :: (Show a => U a) +* A new language extension :extension:`QualifiedDo` is implemented, allowing + to qualify a do block to control which operations to use for desugaring do + syntax. :: + + {-# LANGUAGE QualifiedDo #-} + import qualified SomeModule as M + + f x = M.do -- desugars to: + y <- M.return x -- M.return x M.>>= \y -> + M.return y -- M.return y M.>> + M.return y -- M.return y + + See :ref:`qualified-do-notation` for more details. + Compiler ~~~~~~~~ |