1. 05 Jun, 2020 1 commit
    • Simon Peyton Jones's avatar
      Simple subsumption · 2b792fac
      Simon Peyton Jones authored
      This patch simplifies GHC to use simple subsumption.
        Ticket #17775
      
      Implements GHC proposal #287
         https://github.com/ghc-proposals/ghc-proposals/blob/master/
         proposals/0287-simplify-subsumption.rst
      
      All the motivation is described there; I will not repeat it here.
      The implementation payload:
       * tcSubType and friends become noticably simpler, because it no
         longer uses eta-expansion when checking subsumption.
       * No deeplyInstantiate or deeplySkolemise
      
      That in turn means that some tests fail, by design; they can all
      be fixed by eta expansion.  There is a list of such changes below.
      
      Implementing the patch led me into a variety of sticky corners, so
      the patch includes several othe changes, some quite significant:
      
      * I made String wired-in, so that
          "foo" :: String   rather than
          "foo" :: [Char]
        This improves error messages, and fixes #15679
      
      * The pattern match checker relies on knowing about in-scope equality
        constraints, andd adds them to the desugarer's environment using
        addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
        simple-subsumption ends up with dictionaries there. So I added a
        call to addTyCsDs.  This is really part of #18049.
      
      * I moved the ic_telescope field out of Implication and into
        ForAllSkol instead.  This is a nice win; just expresses the code
        much better.
      
      * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
        We called checkDataKindSig inside tc_kind_sig, /before/
        solveEqualities and zonking.  Obviously wrong, easily fixed.
      
      * solveLocalEqualitiesX: there was a whole mess in here, around
        failing fast enough.  I discovered a bad latent bug where we
        could successfully kind-check a type signature, and use it,
        but have unsolved constraints that could fill in coercion
        holes in that signature --  aargh.
      
        It's all explained in Note [Failure in local type signatures]
        in GHC.Tc.Solver. Much better now.
      
      * I fixed a serious bug in anonymous type holes. IN
          f :: Int -> (forall a. a -> _) -> Int
        that "_" should be a unification variable at the /outer/
        level; it cannot be instantiated to 'a'.  This was plain
        wrong.  New fields mode_lvl and mode_holes in TcTyMode,
        and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.
      
        This fixes #16292, but makes no progress towards the more
        ambitious #16082
      
      * I got sucked into an enormous refactoring of the reporting of
        equality errors in GHC.Tc.Errors, especially in
            mkEqErr1
            mkTyVarEqErr
            misMatchMsg
            misMatchMsgOrCND
        In particular, the very tricky mkExpectedActualMsg function
        is gone.
      
        It took me a full day.  But the result is far easier to understand.
        (Still not easy!)  This led to various minor improvements in error
        output, and an enormous number of test-case error wibbles.
      
        One particular point: for occurs-check errors I now just say
           Can't match 'a' against '[a]'
        rather than using the intimidating language of "occurs check".
      
      * Pretty-printing AbsBinds
      
      Tests review
      
      * Eta expansions
         T11305: one eta expansion
         T12082: one eta expansion (undefined)
         T13585a: one eta expansion
         T3102:  one eta expansion
         T3692:  two eta expansions (tricky)
         T2239:  two eta expansions
         T16473: one eta
         determ004: two eta expansions (undefined)
         annfail06: two eta (undefined)
         T17923: four eta expansions (a strange program indeed!)
         tcrun035: one eta expansion
      
      * Ambiguity check at higher rank.  Now that we have simple
        subsumption, a type like
           f :: (forall a. Eq a => Int) -> Int
        is no longer ambiguous, because we could write
           g :: (forall a. Eq a => Int) -> Int
           g = f
        and it'd typecheck just fine.  But f's type is a bit
        suspicious, and we might want to consider making the
        ambiguity check do a check on each sub-term.  Meanwhile,
        these tests are accepted, whereas they were previously
        rejected as ambiguous:
           T7220a
           T15438
           T10503
           T9222
      
      * Some more interesting error message wibbles
         T13381: Fine: one error (Int ~ Exp Int)
                 rather than two (Int ~ Exp Int, Exp Int ~ Int)
         T9834:  Small change in error (improvement)
         T10619: Improved
         T2414:  Small change, due to order of unification, fine
         T2534:  A very simple case in which a change of unification order
                 means we get tow unsolved constraints instead of one
         tc211: bizarre impredicative tests; just accept this for now
      
      Updates Cabal and haddock submodules.
      
      Metric Increase:
        T12150
        T12234
        T5837
        haddock.base
      Metric Decrease:
        haddock.compiler
        haddock.Cabal
        haddock.base
      
      Merge note: This appears to break the
      `UnliftedNewtypesDifficultUnification` test. It has been marked as
      broken in the interest of merging.
      
      (cherry picked from commit 66b7b195)
      2b792fac
  2. 24 May, 2020 1 commit
  3. 21 May, 2020 2 commits
    • Stefan Holdermans's avatar
      Allow GHCi :script file names in double quotes · a0b79e1b
      Stefan Holdermans authored
      This patch updates the user interface of GHCi so that file names passed
      to the ':script' command can be wrapped in double quotes.
      
      For example:
      
        :script "foo bar.script"
      
      The implementation uses a modified version of 'words' that treats
      character sequences enclosed in double quotes as single words.
      
      Fixes #18027.
      a0b79e1b
    • Stefan Holdermans's avatar
      Allow spaces in GHCi :script file names · a8c27cf6
      Stefan Holdermans authored
      This patch updates the user interface of GHCi so that file names passed
      to the ':script' command may contain spaces escaped with a backslash.
      
      For example:
      
        :script foo\ bar.script
      
      The implementation uses a modified version of 'words' that does not
      break on escaped spaces.
      
      Fixes #18027.
      a8c27cf6
  4. 14 May, 2020 1 commit
  5. 06 May, 2020 1 commit
  6. 04 May, 2020 1 commit
  7. 01 May, 2020 1 commit
  8. 30 Apr, 2020 3 commits
    • Sylvain Henry's avatar
      Unit: split and rename modules · 8bfb0219
      Sylvain Henry authored
      Introduce GHC.Unit.* hierarchy for everything concerning units, packages
      and modules.
      
      Update Haddock submodule
      8bfb0219
    • Sylvain Henry's avatar
      Refactoring unit management code · 10d15f1e
      Sylvain Henry authored
      Over the years the unit management code has been modified a lot to keep
      up with changes in Cabal (e.g. support for several library components in
      the same package), to integrate BackPack, etc. I found it very hard to
      understand as the terminology wasn't consistent, was referring to past
      concepts, etc.
      
      The terminology is now explained as clearly as I could in the Note
      "About Units" and the code is refactored to reflect it.
      
      -------------------
      
      Many names were misleading: UnitId is not an Id but could be a virtual
      unit (an indefinite one instantiated on the fly), IndefUnitId
      constructor may contain a definite instantiated unit, etc.
      
         * Rename IndefUnitId into InstantiatedUnit
         * Rename IndefModule into InstantiatedModule
         * Rename UnitId type into Unit
         * Rename IndefiniteUnitId constructor into VirtUnit
         * Rename DefiniteUnitId constructor into RealUnit
         * Rename packageConfigId into mkUnit
         * Rename getPackageDetails into unsafeGetUnitInfo
         * Rename InstalledUnitId into UnitId
      
      Remove references to misleading ComponentId: a ComponentId is just an
      indefinite unit-id to be instantiated.
      
         * Rename ComponentId into IndefUnitId
         * Rename ComponentDetails into UnitPprInfo
         * Fix display of UnitPprInfo with empty version: this is now used for
           units dynamically generated by BackPack
      
      Generalize several types (Module, Unit, etc.) so that they can be used
      with different unit identifier types: UnitKey, UnitId, Unit, etc.
      
         * GenModule: Module, InstantiatedModule and InstalledModule are now
           instances of this type
         * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
           PackageDatabase
      
      Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.
      
      Add basic support for UnitKey. They should be used more in the future to
      avoid mixing them up with UnitId as we do now.
      
      Add many comments.
      
      Update Haddock submodule
      10d15f1e
    • Sylvain Henry's avatar
      Refactor UnitInfo · 10a2ba90
      Sylvain Henry authored
      * Rename InstalledPackageInfo into GenericUnitInfo
      
      The name InstalledPackageInfo is only kept for alleged backward
      compatibility reason in Cabal. ghc-boot has its own stripped down copy
      of this datatype but it doesn't need to keep the name. Internally we
      already use type aliases (UnitInfo in GHC, PackageCacheFormat in
      ghc-pkg).
      
      * Rename UnitInfo fields: add "unit" prefix and fix misleading names
      
      * Add comments on every UnitInfo field
      
      * Rename SourcePackageId into PackageId
      
      "Package" already indicates that it's a "source package". Installed
      package components are called units.
      
      Update Haddock submodule
      10a2ba90
  9. 26 Apr, 2020 1 commit
  10. 23 Apr, 2020 1 commit
    • Roland Senn's avatar
      Fix tab-completion for :break (#17989) · 48b8951e
      Roland Senn authored
      In tab-completion for the `:break` command, only those
      identifiers should be shown, that are accepted in the
      `:break` command. Hence these identifiers must be
      
      - defined in an interpreted module
      - top-level
      - currently in scope
      - listed in a `ModBreaks` value as a possible breakpoint.
      
      The identifiers my be qualified or unqualified.
      
      To get all possible top-level breakpoints for tab-completeion
      with the correct qualification do:
      
      1. Build the  list called `pifsBreaks` of all pairs of
      (Identifier, module-filename) from the `ModBreaks` values.
      Here all identifiers are unqualified.
      
      2. Build the list called `pifInscope` of all pairs of
      (Identifiers, module-filename) with identifiers from
      the `GlobalRdrEnv`. Take only those identifiers that are
      in scope and have the  correct prefix.
      Here the identifiers may be qualified.
      
      3. From the `pifInscope` list seclect all pairs that can be
      found in the `pifsBreaks` list, by comparing only the
      unqualified part of the identifier.
      The remaining identifiers can be used for tab-completion.
      
      This ensures, that we show only identifiers, that can be used
      in a `:break` command.
      48b8951e
  11. 21 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      Use ParserFlags in GHC.Runtime.Eval (#17957) · 6655f933
      Sylvain Henry authored
      Instead of passing `DynFlags` to functions such as `isStmt` and
      `hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much
      simpler structure that can be created purely with `mkParserFlags'`.
      6655f933
  12. 18 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      Modules (#13009) · 15312bbb
      Sylvain Henry authored
      * SysTools
      * Parser
      * GHC.Builtin
      * GHC.Iface.Recomp
      * Settings
      
      Update Haddock submodule
      
      Metric Decrease:
          Naperian
          parsing001
      15312bbb
  13. 07 Apr, 2020 1 commit
  14. 29 Mar, 2020 2 commits
    • Sylvain Henry's avatar
      Store ComponentId details · e54500c1
      Sylvain Henry authored
      As far as GHC is concerned, installed package components ("units") are
      identified by an opaque ComponentId string provided by Cabal. But we
      don't want to display it to users (as it contains a hash) so GHC queries
      the database to retrieve some infos about the original source package
      (name, version, component name).
      
      This patch caches these infos in the ComponentId itself so that we don't
      need to provide DynFlags (which contains installed package informations)
      to print a ComponentId.
      
      In the future we want GHC to support several independent package states
      (e.g. for plugins and for target code), hence we need to avoid
      implicitly querying a single global package state.
      e54500c1
    • Sylvain Henry's avatar
      Modules: Types (#13009) · 1941ef4f
      Sylvain Henry authored
      Update Haddock submodule
      
      Metric Increase:
         haddock.compiler
      1941ef4f
  15. 29 Feb, 2020 2 commits
    • Sylvain Henry's avatar
      Refactor runtime interpreter code · 18757cab
      Sylvain Henry authored
      In #14335 we want to be able to use both the internal interpreter (for
      the plugins) and the external interpreter (for TH and GHCi) at the same
      time.
      
      This patch performs some preliminary refactoring: the `hsc_interp` field
      of HscEnv replaces `hsc_iserv` and is now used to indicate which
      interpreter (internal, external) to use to execute TH and GHCi.
      
      Opt_ExternalInterpreter flag and iserv options in DynFlags are now
      queried only when we set the session DynFlags. It should help making GHC
      multi-target in the future by selecting an interpreter according to the
      selected target.
      18757cab
    • Vladislav Zavialov's avatar
      Monotonic locations (#17632) · 327b29e1
      Vladislav Zavialov authored
      When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the
      tool may insert #line pragmas to adjust the locations reported to the user.
      
      As the result, the locations recorded in RealSrcLoc are not monotonic. Elements
      that appear later in the StringBuffer are not guaranteed to have a higher
      line/column number.
      
      In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily
      modify locations. This lack of guarantees makes ideas such as #17544
      infeasible.
      
      This patch adds an additional bit of information to every SrcLoc:
      
      	newtype BufPos = BufPos { bufPos :: Int }
      
      A BufPos represents the location in the StringBuffer, unaffected by any
      pragmas.
      
      Updates haddock submodule.
      
      Metric Increase:
          haddock.Cabal
          haddock.base
          haddock.compiler
          MultiLayerModules
          Naperian
          parsing001
          T12150
      327b29e1
  16. 26 Feb, 2020 1 commit
  17. 24 Feb, 2020 1 commit
    • Vladislav Zavialov's avatar
      Remove Ord SrcLoc, Ord SrcSpan · 26e8fff3
      Vladislav Zavialov authored
      Before this patch, GHC relied on Ord SrcSpan to identify source elements, by
      using SrcSpan as Map keys:
      
      	blackList :: Map SrcSpan ()      -- compiler/GHC/HsToCore/Coverage.hs
      	instanceMap :: Map SrcSpan Name  -- compiler/GHC/HsToCore/Docs.hs
      
      Firstly, this design is not valid in presence of UnhelpfulSpan, as it
      distinguishes between  UnhelpfulSpan "X"  and  UnhelpfulSpan "Y", but those
      strings are messages for the user, unfit to serve as identifiers for source
      elements.
      
      Secondly, this design made it hard to extend SrcSpan with additional data.
      Recall that the definition of SrcSpan is:
      
      	data SrcSpan =
      	    RealSrcSpan !RealSrcSpan
      	  | UnhelpfulSpan !FastString
      
      Say we want to extend the RealSrcSpan constructor with additional information:
      
      	data SrcSpan =
      	    RealSrcSpan !RealSrcSpan !AdditionalInformation
      	  | UnhelpfulSpan !FastString
      
      	getAdditionalInformation :: SrcSpan -> AdditionalInformation
      	getAdditionalInformation (RealSrcSpan _ a) = a
      
      Now, in order for  Map SrcSpan  to keep working correctly, we must *ignore* additional
      information when comparing SrcSpan values:
      
      	instance Ord SrcSpan where
      	  compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2
      	  ...
      
      However, this would violate an important law:
      
      	a == b  therefore  f a == f b
      
      Ignoring  AdditionalInformation  in comparisons would mean that with
      f=getAdditionalInformation, the law above does not hold.
      
      A more robust design is to avoid  Ord SrcSpan  altogether, which is what this patch implements.
      The mappings are changed to use RealSrcSpan instead:
      
      	blackList :: Set RealSrcSpan         -- compiler/GHC/HsToCore/Coverage.hs
      	instanceMap :: Map RealSrcSpan Name  -- compiler/GHC/HsToCore/Docs.hs
      
      All SrcSpan comparisons are now done with explicit comparison strategies:
      
      	SrcLoc.leftmost_smallest
      	SrcLoc.leftmost_largest
      	SrcLoc.rightmost_smallest
      
      These strategies are not subject to the law mentioned above and can easily
      discard both the string stored in  UnhelpfulSpan  and  AdditionalInformation.
      
      Updates haddock submodule.
      26e8fff3
  18. 22 Feb, 2020 1 commit
  19. 12 Feb, 2020 1 commit
  20. 13 Jan, 2020 1 commit
  21. 06 Jan, 2020 1 commit
  22. 24 Nov, 2019 1 commit
  23. 26 Oct, 2019 2 commits
    • Ömer Sinan Ağacan's avatar
      Remove redundant -fno-cse options · 4054f0e5
      Ömer Sinan Ağacan authored
      These were probably added with some GLOBAL_VARs, but those GLOBAL_VARs
      are now gone.
      4054f0e5
    • Roland Senn's avatar
      Fix #14690 - :steplocal panics after break-on-error · 1be9c35c
      Roland Senn authored
      `:steplocal` enables only breakpoints in the current top-level binding.
      
      When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code
      allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan
      (see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint).
      With this source-span we can then determine the current top-level binding, needed for the steplocal command.
      
      However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information.
      The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding.
      To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`.
      Hence a :steplocal command after a break-on-exception or a break-on-error is not possible.
      1be9c35c
  24. 23 Oct, 2019 1 commit
    • Takenobu Tani's avatar
      Allow command name resolution for GHCi commands with option `!` #17345 · 4798f3b9
      Takenobu Tani authored
      This commit allows command name resolution for GHCi commands
      with option `!` as follows:
      
          ghci> :k! Int
          Int :: *
          = Int
      
      This commit changes implementation as follows:
      
      Before:
        * Prefix match with full string including the option `!` (e.g. `k!`)
      
      After (this patch):
        * Prefix match without option suffix `!` (e.g. `k`)
        * in addition, suffix match with option `!`
      
      See also #8305 and #8113
      4798f3b9
  25. 13 Oct, 2019 1 commit
  26. 07 Oct, 2019 1 commit
  27. 01 Oct, 2019 1 commit
  28. 20 Sep, 2019 1 commit
  29. 09 Jul, 2019 1 commit
    • Ryan Scott's avatar
      Use an empty data type in TTG extension constructors (#15247) · 6a03d77b
      Ryan Scott authored
      To avoid having to `panic` any time a TTG extension constructor is
      consumed, this MR introduces an uninhabited 'NoExtCon' type and uses
      that in every extension constructor's type family instance where it
      is appropriate. This also introduces a 'noExtCon' function which
      eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates
      a 'Void'.
      
      I also renamed the existing `NoExt` type to `NoExtField` to better
      distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of
      code churn resulting from this.
      
      Bumps the Haddock submodule. Fixes #15247.
      6a03d77b
  30. 20 Jun, 2019 1 commit
    • Roland Senn's avatar
      Fix #1620: ModBreaks.modBreaks_array not initialised · 39c758e1
      Roland Senn authored
      After a :cd command and after setting some package flags,
      GHCi unloads all loaded modules by resetting the list of targets.
      
      This patch deletes eventually defined debugger breakpoints, before GHCi resets the target list.
      
      The common code is factored out into the new function clearAllTargets.
      39c758e1
  31. 09 Jun, 2019 1 commit
    • Roland Senn's avatar
      Add disable/enable commands to ghci debugger #2215 · 10452959
      Roland Senn authored
      This patch adds two new commands `:enable` and `:disable` to the GHCi debugger.
      Opposite to `:set stop <n> :continue` a breakpoint disabled with `:disable` will
      not loose its previously set stop command.
      A new field breakEnabled is added to the BreakLocation data structure to
      track the enable/disable state. When a breakpoint is disabled with a `:disable`
      command, the following happens:
      
      The corresponding BreakLocation data element is searched dictionary of the
      `breaks` field of the GHCiStateMonad. If the break point is found and not
      already in the disabled state, the breakpoint is removed from bytecode.
      The BreakLocation data structure is kept in the breaks list and the new
      breakEnabled field is set to false.
      
      The `:enable` command works similar.
      
      The breaks field in the GHCiStateMonad was changed from an association list
      to int `IntMap`.
      10452959
  32. 07 Jun, 2019 1 commit
  33. 04 Jun, 2019 1 commit
    • xldenis's avatar
      Add GHCi :instances command · 002594b7
      xldenis authored
      This commit adds the `:instances` command to ghci following proosal
      number 41.
      
      This makes it possible to query which instances are available to a given
      type.
      
      The output of this command is all the possible instances with type
      variables and constraints instantiated.
      002594b7
  34. 22 May, 2019 1 commit