diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2014-01-26 11:36:23 +0000 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2014-11-02 19:03:28 +0100 |
commit | c271e32eac65ee95ba1aacc72ed1b24b58ef17ad (patch) | |
tree | fc9ea34e09f44452b4e6328cbe665b30a3e40ee5 /libraries/ghc-prim | |
parent | c001bde73e38904ed161b0b61b240f99a3b6f48d (diff) | |
download | haskell-c271e32eac65ee95ba1aacc72ed1b24b58ef17ad.tar.gz |
Add GHC.Prim.oneShot
to allow the programer to explictitly set the oneShot flag. This helps
with #7994 and will be used in left folds. Also see
https://ghc.haskell.org/trac/ghc/wiki/OneShot
This commit touches libraries/base/GHC/Event/Manager.hs (which used to
have a local definition of the name oneShot) to avoid a shadowing error.
Differential Revision: https://phabricator.haskell.org/D392
Diffstat (limited to 'libraries/ghc-prim')
-rw-r--r-- | libraries/ghc-prim/GHC/Magic.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libraries/ghc-prim/GHC/Magic.hs b/libraries/ghc-prim/GHC/Magic.hs index 081b838c46..1a6af9237d 100644 --- a/libraries/ghc-prim/GHC/Magic.hs +++ b/libraries/ghc-prim/GHC/Magic.hs @@ -17,7 +17,7 @@ -- ----------------------------------------------------------------------------- -module GHC.Magic ( inline, lazy ) where +module GHC.Magic ( inline, lazy, oneShot ) where -- | The call @inline f@ arranges that 'f' is inlined, regardless of -- its size. More precisely, the call @inline f@ rewrites to the @@ -64,3 +64,12 @@ lazy x = x -- sees it as lazy. Then the worker/wrapper phase inlines it. -- Result: happiness + +-- | The 'oneShot' function can be used to give a hint to the compiler that its +-- argument will be called at most once, which may (or may not) enable certain +-- optimizations. It can be useful to improve the performance of code in continuation +-- passing style. +oneShot :: (a -> b) -> (a -> b) +oneShot f = f +-- Implementation note: This is wired in in MkId.lhs, so the code here is +-- mostly there to have a place for the documentation. |