Ticket #7061: 0001-Allow-default-declarations-in-GHCi.patch

File 0001-Allow-default-declarations-in-GHCi.patch, 3.2 KB (added by parcs, 2 years ago)
  • compiler/main/HscMain.hs

    From 38fd8e0de2bee1c27bd9bed3c26500e2e119dd21 Mon Sep 17 00:00:00 2001
    From: Patrick Palka <patrick@parcs.ath.cx>
    Date: Sun, 8 Jul 2012 12:49:22 -0400
    Subject: [PATCH] Allow 'default' declarations in GHCi
    
    ---
     compiler/main/HscMain.hs          |    5 ++++-
     compiler/main/HscTypes.lhs        |    4 ++++
     compiler/typecheck/TcRnDriver.lhs |    1 +
     ghc/InteractiveUI.hs              |    2 +-
     4 files changed, 10 insertions(+), 2 deletions(-)
    
    diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
    index 0b03e83..215a654 100644
    a b hscDeclsWithLocation hsc_env0 str source linenumber = 
    15101510    let finsts = tcg_fam_insts tc_gblenv 
    15111511        insts  = tcg_insts     tc_gblenv 
    15121512 
     1513    let defaults = tcg_default tc_gblenv 
     1514 
    15131515    {- Desugar it -} 
    15141516    -- We use a basically null location for iNTERACTIVE 
    15151517    let iNTERACTIVELoc = ModLocation{ ml_hs_file   = Nothing, 
    hscDeclsWithLocation hsc_env0 str source linenumber = 
    15611563 
    15621564    let ictxt1 = extendInteractiveContext icontext tythings 
    15631565        ictxt  = ictxt1 { ic_sys_vars  = sys_vars ++ ic_sys_vars ictxt1, 
    1564                           ic_instances = (insts, finsts) } 
     1566                          ic_instances = (insts, finsts), 
     1567                          ic_default   = defaults } 
    15651568 
    15661569    return (tythings, ictxt) 
    15671570 
  • compiler/main/HscTypes.lhs

    diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs
    index adaa9a3..343df00 100644
    a b data InteractiveContext 
    943943             -- ^ The function that is used for printing results 
    944944             -- of expressions in ghci and -e mode. 
    945945 
     946         ic_default :: Maybe [Type], 
     947             -- ^ The current default types, set by a 'default' declaration 
     948 
    946949#ifdef GHCI 
    947950          ic_resume :: [Resume], 
    948951             -- ^ The stack of breakpoint contexts 
    emptyInteractiveContext dflags 
    987990                         ic_fix_env    = emptyNameEnv, 
    988991                         -- System.IO.print by default 
    989992                         ic_int_print  = printName, 
     993                         ic_default    = Nothing, 
    990994#ifdef GHCI 
    991995                         ic_resume     = [], 
    992996#endif 
  • compiler/typecheck/TcRnDriver.lhs

    diff --git a/compiler/typecheck/TcRnDriver.lhs b/compiler/typecheck/TcRnDriver.lhs
    index fa87eb1..5bfb091 100644
    a b setInteractiveContext hsc_env icxt thing_inside 
    11971197             -- setting tcg_field_env is necessary to make RecordWildCards work 
    11981198             -- (test: ghci049) 
    11991199        , tcg_fix_env      = ic_fix_env icxt 
     1200        , tcg_default      = ic_default icxt 
    12001201        }) $ 
    12011202 
    12021203        tcExtendGhciEnv visible_tmp_ids $ -- Note [GHCi temporary Ids] 
  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 1dc203d..d73156e 100644
    a b enqueueCommands cmds = do 
    768768-- rather than a stmt. 
    769769declPrefixes :: [String] 
    770770declPrefixes = ["class ","data ","newtype ","type ","instance ", "deriving ", 
    771                 "foreign "] 
     771                "foreign ", "default ", "default("] 
    772772 
    773773-- | Entry point to execute some haskell code from user 
    774774runStmt :: String -> SingleStep -> GHCi Bool