Commit 520d82b6 authored by parcs's avatar parcs Committed by Simon Marlow

Allow 'default' declarations in GHCi

parent 5b93af46
......@@ -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)
......
......@@ -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
......
......@@ -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]
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment