[commit: ghc] master: Special case for desugaring AbsBinds (a81e9d5)

git at git.haskell.org git at git.haskell.org
Fri Feb 26 17:14:43 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a81e9d57439f338ac3c202b929b4b9e991ee7c20/ghc

>---------------------------------------------------------------

commit a81e9d57439f338ac3c202b929b4b9e991ee7c20
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Feb 25 15:53:59 2016 +0000

    Special case for desugaring AbsBinds
    
    When AbsBinds has no tyvars and no dicts, a rather simpler
    desugaring is possible.  This patch implements it.
    
    I don't think the optimised code changes, but there is
    less clutter generated.


>---------------------------------------------------------------

a81e9d57439f338ac3c202b929b4b9e991ee7c20
 compiler/deSugar/DsBinds.hs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/compiler/deSugar/DsBinds.hs b/compiler/deSugar/DsBinds.hs
index 72b74c7..da20686 100644
--- a/compiler/deSugar/DsBinds.hs
+++ b/compiler/deSugar/DsBinds.hs
@@ -184,6 +184,26 @@ dsHsBind dflags
 
        ; return ([], main_bind : fromOL spec_binds) }
 
+        -- Another common case: no tyvars, no dicts
+        -- In this case we can have a much simpler desugaring
+dsHsBind dflags
+         (AbsBinds { abs_tvs = [], abs_ev_vars = []
+                   , abs_exports = exports
+                   , abs_ev_binds = ev_binds, abs_binds = binds })
+  = do { (force_vars, bind_prs) <- ds_lhs_binds binds
+       ; let mk_bind (ABE { abe_wrap = wrap
+                          , abe_poly = global
+                          , abe_mono = local
+                          , abe_prags = prags })
+              = do { rhs <- dsHsWrapper wrap (Var local)
+                   ; return (makeCorePair dflags global
+                                          (isDefaultMethod prags)
+                                          0 rhs) }
+       ; main_binds <- mapM mk_bind exports
+
+       ; ds_binds <- dsTcEvBinds_s ev_binds
+       ; return (force_vars, flattenBinds ds_binds ++ bind_prs ++ main_binds) }
+
 dsHsBind dflags
          (AbsBinds { abs_tvs = tyvars, abs_ev_vars = dicts
                    , abs_exports = exports, abs_ev_binds = ev_binds



More information about the ghc-commits mailing list