Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/520d82b6ea81b39fcea6b4c06e40b38b85745599 >--------------------------------------------------------------- commit 520d82b6ea81b39fcea6b4c06e40b38b85745599 Author: Patrick Palka <[email protected]> Date: Sun Jul 8 12:49:22 2012 -0400 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/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -1510,6 +1510,8 @@ hscDeclsWithLocation hsc_env0 str source linenumber = let finsts = tcg_fam_insts tc_gblenv insts = tcg_insts tc_gblenv + let defaults = tcg_default tc_gblenv + {- Desugar it -} -- We use a basically null location for iNTERACTIVE let iNTERACTIVELoc = ModLocation{ ml_hs_file = Nothing, @@ -1561,7 +1563,8 @@ hscDeclsWithLocation hsc_env0 str source linenumber = let ictxt1 = extendInteractiveContext icontext tythings ictxt = ictxt1 { ic_sys_vars = sys_vars ++ ic_sys_vars ictxt1, - ic_instances = (insts, finsts) } + ic_instances = (insts, finsts), + ic_default = defaults } return (tythings, ictxt) diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs index adaa9a3..343df00 100644 --- a/compiler/main/HscTypes.lhs +++ b/compiler/main/HscTypes.lhs @@ -943,6 +943,9 @@ data InteractiveContext -- ^ The function that is used for printing results -- of expressions in ghci and -e mode. + ic_default :: Maybe [Type], + -- ^ The current default types, set by a 'default' declaration + #ifdef GHCI ic_resume :: [Resume], -- ^ The stack of breakpoint contexts @@ -987,6 +990,7 @@ emptyInteractiveContext dflags ic_fix_env = emptyNameEnv, -- System.IO.print by default ic_int_print = printName, + ic_default = Nothing, #ifdef GHCI ic_resume = [], #endif diff --git a/compiler/typecheck/TcRnDriver.lhs b/compiler/typecheck/TcRnDriver.lhs index e3ec10a..0d00fb6 100644 --- a/compiler/typecheck/TcRnDriver.lhs +++ b/compiler/typecheck/TcRnDriver.lhs @@ -1197,6 +1197,7 @@ setInteractiveContext hsc_env icxt thing_inside -- setting tcg_field_env is necessary to make RecordWildCards work -- (test: ghci049) , tcg_fix_env = ic_fix_env icxt + , tcg_default = ic_default icxt }) $ tcExtendGhciEnv visible_tmp_ids $ -- Note [GHCi temporary Ids] diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 0dbd8ce..fd5337d 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -794,7 +794,7 @@ enqueueCommands cmds = do -- rather than a stmt. declPrefixes :: [String] declPrefixes = ["class ","data ","newtype ","type ","instance ", "deriving ", - "foreign "] + "foreign ", "default ", "default("] -- | Entry point to execute some haskell code from user runStmt :: String -> SingleStep -> GHCi Bool _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
