[commit: ghc] wip/T16197: Change comments as requested by code review. #10857 (f78048f)

git at git.haskell.org git at git.haskell.org
Thu Jan 17 13:58:15 UTC 2019


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

On branch  : wip/T16197
Link       : http://ghc.haskell.org/trac/ghc/changeset/f78048f6575b370f078bcddc6b9e64bfe23932eb/ghc

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

commit f78048f6575b370f078bcddc6b9e64bfe23932eb
Author: Roland Senn <rsx at bluewin.ch>
Date:   Thu Dec 27 15:14:31 2018 +0100

    Change comments as requested by code review. #10857


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

f78048f6575b370f078bcddc6b9e64bfe23932eb
 compiler/main/DynFlags.hs |  2 +-
 ghc/GHCi/UI.hs            | 33 +++++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index ccc2a05..78be688 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -2382,7 +2382,7 @@ xopt_unset dfs f
       in dfs { extensions = onoffs,
                extensionFlags = flattenExtensionFlags (language dfs) onoffs }
 
--- | Set or unset a 'LangExt.Extension', unless it has been explicitely
+-- | Set or unset a 'LangExt.Extension', unless it has been explicitly
 --   set or unset before.
 xopt_set_unlessExplSpec
         :: LangExt.Extension
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 3a26dfe..0c09844 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -433,12 +433,7 @@ interactiveUI config srcs maybe_exprs = do
    -- The initial set of DynFlags used for interactive evaluation is the same
    -- as the global DynFlags, plus -XExtendedDefaultRules and
    -- -XNoMonomorphismRestriction.
-   -- However we set/unset these two extensions only, if they were not already
-   -- explicitely specified before. The function 'xopt_set_unlessExplSpec'
-   -- inspects the data field DynFlags.extensions.
-   -- At this point of the GHCi initialization this data field contains only
-   -- the extensions specified at the command line.
-   -- The ghci config file has not yet been processed. (#10857)
+   -- See note [Changing language extensions for interactive evaluation] #10857
    dflags <- getDynFlags
    let dflags' = (xopt_set_unlessExplSpec
                       LangExt.ExtendedDefaultRules xopt_set)
@@ -509,6 +504,32 @@ interactiveUI config srcs maybe_exprs = do
 
    return ()
 
+{-
+Note [Changing language extensions for interactive evaluation]
+--------------------------------------------------------------
+GHCi maintains two sets of options:
+
+- The "loading options" apply when loading modules
+- The "interactive options" apply when evaluating expressions and commands
+    typed at the GHCi prompt.
+
+The loading options are mostly created in ghc/Main.hs:main' from the command
+line flags. In the function ghc/GHCi/UI.hs:interactiveUI the loading options
+are copied to the interactive options.
+
+These interactive options (but not the loading options!) are supplemented
+unconditionally by setting ExtendedDefaultRules ON and
+MonomorphismRestriction OFF. The unconditional setting of these options
+eventually overwrite settings already specified at the command line.
+
+Therefore instead of unconditionally setting ExtendedDefaultRules and
+NoMonomorphismRestriction for the interactive options, we use the function
+'xopt_set_unlessExplSpec' to first check whether the extension has already
+specified at the command line.
+
+The ghci config file has not yet been processed.
+-}
+
 resetLastErrorLocations :: GHCi ()
 resetLastErrorLocations = do
     st <- getGHCiState



More information about the ghc-commits mailing list