Skip to content

Commit

Permalink
[ agda#4647 ] option --top-level-interaction-no-private to disable fix
Browse files Browse the repository at this point in the history
Should the new behavior of top-level interaction commands (reload on
not-in-scope errors) be disruptive to one's workflow, this option brings
back the old behavior (with private declarations not in scope).
  • Loading branch information
andreasabel authored and jespercockx committed May 21, 2020
1 parent 841b347 commit 88c4689
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/full/Agda/Interaction/InteractionTop.hs
@@ -1,5 +1,6 @@
{-# OPTIONS_GHC -fno-cse #-}
{-# LANGUAGE NondecreasingIndentation #-}

{-# OPTIONS_GHC -fno-cse #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Agda.Interaction.InteractionTop
Expand Down Expand Up @@ -942,6 +943,8 @@ withCurrentFile m = do
-- | Top-level commands switch to 'TopLevelInteraction' mode if necessary.
atTopLevel :: CommandM a -> CommandM a
atTopLevel cmd = do
-- Don't switch if --top-level-interaction-no-private.
ifM (optTopLevelInteractionNoPrivate <$> pragmaOptions) continue $ {-else-} do
gets interactionMode >>= \case
TopLevelInteraction -> continue -- Already in the correct mode.
RegularInteraction -> continue `handleNotInScope` do
Expand Down
10 changes: 10 additions & 0 deletions src/full/Agda/Interaction/Options.hs
Expand Up @@ -166,6 +166,10 @@ data PragmaOptions = PragmaOptions
, optKeepPatternVariables :: Bool
-- ^ Should case splitting replace variables with dot patterns
-- (False) or keep them as variables (True).
, optTopLevelInteractionNoPrivate :: Bool
-- ^ If @True@, disable reloading mechanism introduced in issue #4647
-- that brings private declarations in main module into scope
-- to remedy not-in-scope errors in top-level interaction commands.
, optInstanceSearchDepth :: Int
, optOverlappingInstances :: Bool
, optQualifiedInstances :: Bool -- ^ Should instance search consider instances with qualified names?
Expand Down Expand Up @@ -283,6 +287,7 @@ defaultPragmaOptions = PragmaOptions
, optCubical = False
, optPostfixProjections = False
, optKeepPatternVariables = False
, optTopLevelInteractionNoPrivate = False
, optInstanceSearchDepth = 500
, optOverlappingInstances = False
, optQualifiedInstances = True
Expand Down Expand Up @@ -741,6 +746,9 @@ postfixProjectionsFlag o = return $ o { optPostfixProjections = True }
keepPatternVariablesFlag :: Flag PragmaOptions
keepPatternVariablesFlag o = return $ o { optKeepPatternVariables = True }

topLevelInteractionNoPrivateFlag :: Flag PragmaOptions
topLevelInteractionNoPrivateFlag o = return $ o { optTopLevelInteractionNoPrivate = True }

instanceDepthFlag :: String -> Flag PragmaOptions
instanceDepthFlag s o = do
d <- integerArgument "--instance-search-depth" s
Expand Down Expand Up @@ -1028,6 +1036,8 @@ pragmaOptions =
"make postfix projection notation the default"
, Option [] ["keep-pattern-variables"] (NoArg keepPatternVariablesFlag)
"don't replace variables with dot patterns during case splitting"
, Option [] ["top-level-interaction-no-private"] (NoArg topLevelInteractionNoPrivateFlag)
"in top-level interaction commands, don't reload file to bring private declarations into scope"
, Option [] ["instance-search-depth"] (ReqArg instanceDepthFlag "N")
"set instance search depth to N (default: 500)"
, Option [] ["overlapping-instances"] (NoArg overlappingInstancesFlag)
Expand Down
8 changes: 4 additions & 4 deletions src/full/Agda/TypeChecking/Serialise/Instances/Errors.hs
Expand Up @@ -219,12 +219,12 @@ instance EmbPrj Doc where

instance EmbPrj PragmaOptions where
icod_ = \case
PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx ->
icodeN' PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx
PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy ->
icodeN' PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy

value = vcase $ \case
[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx] ->
valuN PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx
[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp, qq, rr, ss, tt, uu, vv, ww, xx, yy] ->
valuN PragmaOptions a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy
_ -> malformed

instance EmbPrj WarningMode where
Expand Down

0 comments on commit 88c4689

Please sign in to comment.