1. 24 Nov, 2015 1 commit
    • elaforge's avatar
      Rearrange error msgs and add section markers (Trac #11014). · c05fddde
      elaforge authored
      This puts the "Relevant bindings" section at the end.
      
      It uses a TcErrors.Report Monoid to divide messages by importance and
      then mappends them together.  This is not the most efficient way since
      there are various intermediate Reports and list appends, but it probably
      doesn't matter since error messages shouldn't get that large, and are
      usually prepended.  In practice, everything is `important` except
      `relevantBindings`, which is `supplementary`.
      
      ErrMsg's errMsgShortDoc and errMsgExtraInfo were extracted into ErrDoc,
      which has important, context, and suppelementary fields.  Each of those
      three sections is marked with a bullet character, '•' on unicode
      terminals and '*' on ascii terminals.  Since this breaks tons of tests,
      I also modified testlib.normalise_errmsg to strip out '•'s.
      
      --- Additional notes:
      
      To avoid prepending * to an empty doc, I needed to filter empty docs.
      This seemed less error-prone than trying to modify everyone who produces
      SDoc to instead produce Maybe SDoc.  So I added `Outputable.isEmpty`.
      Unfortunately it needs a DynFlags, which is kind of bogus, but otherwise
      I think I'd need another Empty case for SDoc, and then it couldn't be a
      newtype any more.
      
      ErrMsg's errMsgShortString is only used by the Show instance, which is
      in turn only used by Show HscTypes.SourceError, which is in turn only
      needed for the Exception instance.  So it's probably possible to get rid
      of errMsgShortString, but that would a be an unrelated cleanup.
      
      Fixes #11014.
      
      Test Plan: see above
      
      Reviewers: austin, simonpj, thomie, bgamari
      
      Reviewed By: thomie, bgamari
      
      Subscribers: simonpj, nomeata, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1427
      
      GHC Trac Issues: #11014
      c05fddde
  2. 16 Nov, 2015 1 commit
  3. 30 Oct, 2015 2 commits
    • Ben Gamari's avatar
      Generate Typeable info at definition sites · 91c6b1f5
      Ben Gamari authored
      This is the second attempt at merging D757.
      
      This patch implements the idea floated in Trac #9858, namely that we
      should generate type-representation information at the data type
      declaration site, rather than when solving a Typeable constraint.
      
      However, this turned out quite a bit harder than I expected. I still
      think it's the right thing to do, and it's done now, but it was quite
      a struggle.
      
      See particularly
      
       * Note [Grand plan for Typeable] in TcTypeable (which is a new module)
       * Note [The overall promotion story] in DataCon (clarifies existing
      stuff)
      
      The most painful bit was that to generate Typeable instances (ie
      TyConRepName bindings) for every TyCon is tricky for types in ghc-prim
      etc:
      
       * We need to have enough data types around to *define* a TyCon
       * Many of these types are wired-in
      
      Also, to minimise the code generated for each data type, I wanted to
      generate pure data, not CAFs with unpackCString# stuff floating about.
      
      Performance
      ~~~~~~~~~~~
      Three perf/compiler tests start to allocate quite a bit more. This isn't
      surprising, because they all allocate zillions of data types, with
      practically no other code, esp. T1969
      
       * T1969:    GHC allocates 19% more
       * T4801:    GHC allocates 13% more
       * T5321FD:  GHC allocates 13% more
       * T9675:    GHC allocates 11% more
       * T783:     GHC allocates 11% more
       * T5642:    GHC allocates 10% more
      
      I'm treating this as acceptable. The payoff comes in Typeable-heavy
      code.
      
      Remaining to do
      ~~~~~~~~~~~~~~~
      
       * I think that "TyCon" and "Module" are over-generic names to use for
         the runtime type representations used in GHC.Typeable. Better might
      be
         "TrTyCon" and "TrModule". But I have not yet done this
      
       * Add more info the the "TyCon" e.g. source location where it was
         defined
      
       * Use the new "Module" type to help with Trac Trac #10068
      
       * It would be possible to generate TyConRepName (ie Typeable
         instances) selectively rather than all the time. We'd need to persist
         the information in interface files. Lacking a motivating reason I
      have
         not done this, but it would not be difficult.
      
      Refactoring
      ~~~~~~~~~~~
      As is so often the case, I ended up refactoring more than I intended.
      In particular
      
       * In TyCon, a type *family* (whether type or data) is repesented by a
         FamilyTyCon
           * a algebraic data type (including data/newtype instances) is
             represented by AlgTyCon This wasn't true before; a data family
             was represented as an AlgTyCon. There are some corresponding
             changes in IfaceSyn.
      
           * Also get rid of the (unhelpfully named) tyConParent.
      
       * In TyCon define 'Promoted', isomorphic to Maybe, used when things are
         optionally promoted; and use it elsewhere in GHC.
      
       * Cleanup handling of knownKeyNames
      
       * Each TyCon, including promoted TyCons, contains its TyConRepName, if
         it has one. This is, in effect, the name of its Typeable instance.
      
      Updates haddock submodule
      
      Test Plan: Let Harbormaster validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1404
      
      GHC Trac Issues: #9858
      91c6b1f5
    • Simon Peyton Jones's avatar
      Record usage information using GlobalRdrElt · 3e94842d
      Simon Peyton Jones authored
      This patch implements an improvment that I've wanted to do for ages, but
      never gotten around to.
      
      Unused imports are computed based on how imported entities occur (qualified,
      unqualified).   This info was accumulated in tcg_used_rdrnames :: Set RdrName.
      But that was a huge pain, and it got worse when we introduced duplicate
      record fields.
      
      The Right Thing is to record tcg_used_gres :: [GlobalRdrElt], which records
      the GRE *after* filtering with pickGREs.  See Note [GRE filtering] in RdrName.
      This is much, much bette.  This patch deletes quite a bit of code, and is
      conceptually much easier to follow.
      
      Hooray.  There should be no change in functionality.
      3e94842d
  4. 29 Oct, 2015 2 commits
    • Ben Gamari's avatar
      Revert "Generate Typeable info at definition sites" · bbaf76f9
      Ben Gamari authored
      This reverts commit bef2f03e.
      
      This merge was botched
      
      Also reverts haddock submodule.
      bbaf76f9
    • Ben Gamari's avatar
      Generate Typeable info at definition sites · bef2f03e
      Ben Gamari authored
      This patch implements the idea floated in Trac #9858, namely that we
      should generate type-representation information at the data type
      declaration site, rather than when solving a Typeable constraint.
      
      However, this turned out quite a bit harder than I expected. I still
      think it's the right thing to do, and it's done now, but it was quite
      a struggle.
      
      See particularly
      
       * Note [Grand plan for Typeable] in TcTypeable (which is a new module)
       * Note [The overall promotion story] in DataCon (clarifies existing stuff)
      
      The most painful bit was that to generate Typeable instances (ie
      TyConRepName bindings) for every TyCon is tricky for types in ghc-prim
      etc:
      
       * We need to have enough data types around to *define* a TyCon
       * Many of these types are wired-in
      
      Also, to minimise the code generated for each data type, I wanted to
      generate pure data, not CAFs with unpackCString# stuff floating about.
      
      Performance
      ~~~~~~~~~~~
      Three perf/compiler tests start to allocate quite a bit more. This isn't
      surprising, because they all allocate zillions of data types, with
      practically no other code, esp. T1969
      
       * T3294:   GHC allocates 110% more (filed #11030 to track this)
       * T1969:   GHC allocates 30% more
       * T4801:   GHC allocates 14% more
       * T5321FD: GHC allocates 13% more
       * T783:    GHC allocates 12% more
       * T9675:   GHC allocates 12% more
       * T5642:   GHC allocates 10% more
       * T9961:   GHC allocates 6% more
      
       * T9203:   Program allocates 54% less
      
      I'm treating this as acceptable. The payoff comes in Typeable-heavy
      code.
      
      Remaining to do
      ~~~~~~~~~~~~~~~
      
       * I think that "TyCon" and "Module" are over-generic names to use for
         the runtime type representations used in GHC.Typeable. Better might be
         "TrTyCon" and "TrModule". But I have not yet done this
      
       * Add more info the the "TyCon" e.g. source location where it was
         defined
      
       * Use the new "Module" type to help with Trac Trac #10068
      
       * It would be possible to generate TyConRepName (ie Typeable
         instances) selectively rather than all the time. We'd need to persist
         the information in interface files. Lacking a motivating reason I have
         not done this, but it would not be difficult.
      
      Refactoring
      ~~~~~~~~~~~
      As is so often the case, I ended up refactoring more than I intended.
      In particular
      
       * In TyCon, a type *family* (whether type or data) is repesented by a
         FamilyTyCon
           * a algebraic data type (including data/newtype instances) is
             represented by AlgTyCon This wasn't true before; a data family
             was represented as an AlgTyCon. There are some corresponding
             changes in IfaceSyn.
      
           * Also get rid of the (unhelpfully named) tyConParent.
      
       * In TyCon define 'Promoted', isomorphic to Maybe, used when things are
         optionally promoted; and use it elsewhere in GHC.
      
       * Cleanup handling of knownKeyNames
      
       * Each TyCon, including promoted TyCons, contains its TyConRepName, if
         it has one. This is, in effect, the name of its Typeable instance.
      
      Requires update of the haddock submodule.
      
      Differential Revision: https://phabricator.haskell.org/D757
      bef2f03e
  5. 16 Oct, 2015 1 commit
    • Adam Gundry's avatar
      Implement DuplicateRecordFields · b1884b0e
      Adam Gundry authored
      This implements DuplicateRecordFields, the first part of the
      OverloadedRecordFields extension, as described at
      https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields
      
      This includes fairly wide-ranging changes in order to allow multiple
      records within the same module to use the same field names.  Note that
      it does *not* allow record selector functions to be used if they are
      ambiguous, and it does not have any form of type-based disambiguation
      for selectors (but it does for updates). Subsequent parts will make
      overloading selectors possible using orthogonal extensions, as
      described on the wiki pages.  This part touches quite a lot of the
      codebase, and requires changes to several GHC API datatypes in order
      to distinguish between field labels (which may be overloaded) and
      selector function names (which are always unique).
      
      The Haddock submodule has been adapted to compile with the GHC API
      changes, but it will need further work to properly support modules
      that use the DuplicateRecordFields extension.
      
      Test Plan: New tests added in testsuite/tests/overloadedrecflds; these
      will be extended once the other parts are implemented.
      
      Reviewers: goldfire, bgamari, simonpj, austin
      
      Subscribers: sjcjoosten, haggholm, mpickering, bgamari, tibbe, thomie,
      goldfire
      
      Differential Revision: https://phabricator.haskell.org/D761
      b1884b0e
  6. 15 Oct, 2015 1 commit
  7. 21 Sep, 2015 1 commit
    • Edward Z. Yang's avatar
      Unify hsig and hs-boot; add preliminary "hs-boot" merging. · 06d46b1e
      Edward Z. Yang authored
      This patch drops the file level distinction between hs-boot and hsig;
      we figure out which one we are compiling based on whether or not there
      is a corresponding hs file lying around.
      
      To make the "import A" syntax continue to work for bare hs-boot
      files, we also introduce hs-boot merging, which takes an A.hi-boot
      and converts it to an A.hi when there is no A.hs file in scope.
      This will be generalized in Backpack to merge multiple A.hi files together;
      which means we can jettison the "load multiple interface files" functionality.
      
      This works automatically for --make, but for one-shot compilation
      we need a new mode: ghc --merge-requirements A will generate an A.hi/A.o
      from a local A.hi-boot file; Backpack will extend this mechanism further.
      
      Has Haddock submodule update to deal with change in msHsFilePath behavior.
      
          - This commit drops support for the hsig extension. Can
            we support it?  It's annoying because the finder code is
            written with the assumption that where there's an hs-boot
            file, there's always an hs file too.  To support hsig, you'd
            have to probe two locations.  Easier to just not support it.
      
          - #10333 affects us, modifying an hs-boot still doesn't trigger
            recomp.
      
          - See compiler/main/Finder.hs: this diff is very skeevy, but
            it seems to work.
      
          - This code cunningly doesn't drop hs-boot files from the
            "drop hs-boot files" module graph, if they don't have a
            corresponding hs file.  I have no idea if this actually is useful.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari, spinda
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1098
      06d46b1e
  8. 03 Sep, 2015 1 commit
  9. 21 Jul, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor self-boot info · 3c44a46b
      Simon Peyton Jones authored
      This patch is a simple refactoring that prepares for a later one,
      related to Trac #10083.
      
      * Add a field tcg_self_boot :: SelfBootInfo to TcGblEnv,
        where SelfBootInfo is a new data type, describing the
        hi-boot file, if any, for the module being compiled.
      
      * Make tcHiBootIface return SelfBootInfo, a new data type
      
      * Make other functions get SelfBootInfo from the monad.
      
      * Remove tcg_mod_name from TcGblEnv; it was barely used and
        simpler to pass around explicitly.
      3c44a46b
  10. 18 Jun, 2015 1 commit
    • Simon Peyton Jones's avatar
      Rename getCtLoc, setCtLoc · 4a7a6c3a
      Simon Peyton Jones authored
      getCtLoc -> getCtLocM
      setCtLoc -> setCtLocM
      
      These operations are monadic, and I want to introduce a
      pure version of setCtLoc :: Ct -> CtLoc -> Ct
      4a7a6c3a
  11. 11 Jun, 2015 1 commit
  12. 09 Jun, 2015 1 commit
    • thomasw's avatar
      Refactor wild card renaming · 058af6c9
      thomasw authored
      Summary:
      Refactor wild card error reporting
      
      * Merge `HsWildcardTy` and `HsNamedWildcardTy` into one constructor
        `HsWildCardTy` with as field the new type `HsWildCardInfo`, which has two
        constructors: `AnonWildCard` and `NamedWildCard`.
      
      * All partial type checks are removed from `RdrHsSyn.hs` and are now done
        during renaming in order to report better error messages. When wild cards
        are allowed in a type, the new function `rnLHsTypeWithWildCards` (or
        `rnHsSigTypeWithWildCards`) should be used. This will bring the named wild
        cards into scope before renaming them. When this is not done, renaming will
        trigger "Unexpected wild card..." errors.
      
        Unfortunately, this has to be done separately for anonymous wild cards
        because they are given a fresh name during renaming, so they will not cause
        an out-of-scope error. They are handled in `tc_hs_type`, as a special case
        of a lookup that fails.
      
        The previous opt-out approach is replaced with an opt-in approach. No more
        panics because of forgotten checks!
      
      * `[t| _ |]` isn't caught by the above two checks, so it is currently handled
        by a special case. The error message (generated in the `DsM` monad) doesn't
        provide as much context information as the other cases.
      
      * Instead of three (!) functions that walk `HsType`, there is now only one
        pure function called `collectWildCards`.
      
      * Alternative approach: catch all unwanted wild cards in `rnHsTyKi` by looking
        at the `HsDocContext`. This will reduce the number of places to catch
        unwanted wild cards form three to one, and make the error messages more
        uniform, albeit less informative, as the error context for renaming is not
        as informative as the one for type checking. A new constructor of
        `HsDocContext` will be required for pattern synonyms signatures.
      
        Small problem: currently type-class type signatures can't be distinguished
        from type signatures using the `HsDocContext`.
      
      This requires an update to the Haddock submodule.
      
      Test Plan: validate
      
      Reviewers: goldfire, simonpj, austin
      
      Reviewed By: simonpj
      
      Subscribers: bgamari, thomie, goldfire
      
      Differential Revision: https://phabricator.haskell.org/D613
      
      GHC Trac Issues: #10098
      058af6c9
  13. 18 May, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor tuple constraints · ffc21506
      Simon Peyton Jones authored
      Make tuple constraints be handled by a perfectly ordinary
      type class, with the component constraints being the
      superclasses:
          class (c1, c2) => (c2, c2)
      
      This change was provoked by
      
        #10359  inability to re-use a given tuple
                constraint as a whole
      
        #9858   confusion between term tuples
                and constraint tuples
      
      but it's generally a very nice simplification. We get rid of
       -  In Type, the TuplePred constructor of PredTree,
          and all the code that dealt with TuplePreds
       -  In TcEvidence, the constructors EvTupleMk, EvTupleSel
      
      See Note [How tuples work] in TysWiredIn.
      
      Of course, nothing is ever entirely simple. This one
      proved quite fiddly.
      
      - I did quite a bit of renaming, which makes this patch
        touch a lot of modules. In partiuclar tupleCon -> tupleDataCon.
      
      - I made constraint tuples known-key rather than wired-in.
        This is different to boxed/unboxed tuples, but it proved
        awkward to have all the superclass selectors wired-in.
        Easier just to use the standard mechanims.
      
      - While I was fiddling with known-key names, I split the TH Name
        definitions out of DsMeta into a new module THNames.  That meant
        that the known-key names can all be gathered in PrelInfo, without
        causing module loops.
      
      - I found that the parser was parsing an import item like
            T( .. )
        as a *data constructor* T, and then using setRdrNameSpace to
        fix it.  Stupid!  So I changed the parser to parse a *type
        constructor* T, which means less use of setRdrNameSpace.
      
        I also improved setRdrNameSpace to behave better on Exact Names.
        Largely on priciple; I don't think it matters a lot.
      
      - When compiling a data type declaration for a wired-in thing like
        tuples (,), or lists, we don't really need to look at the
        declaration.  We have the wired-in thing!  And not doing so avoids
        having to line up the uniques for data constructor workers etc.
        See Note [Declarations for wired-in things]
      
      - I found that FunDeps.oclose wasn't taking superclasses into
        account; easily fixed.
      
      - Some error message refactoring for invalid constraints in TcValidity
      
      - Haddock needs to absorb the change too; so there is a submodule update
      ffc21506
  14. 14 May, 2015 1 commit
  15. 13 May, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor tuple constraints · 130e93aa
      Simon Peyton Jones authored
      Make tuple constraints be handled by a perfectly ordinary
      type class, with the component constraints being the
      superclasses:
          class (c1, c2) => (c2, c2)
      
      This change was provoked by
      
        #10359  inability to re-use a given tuple
                constraint as a whole
      
        #9858   confusion between term tuples
                and constraint tuples
      
      but it's generally a very nice simplification. We get rid of
       -  In Type, the TuplePred constructor of PredTree,
          and all the code that dealt with TuplePreds
       -  In TcEvidence, the constructors EvTupleMk, EvTupleSel
      
      See Note [How tuples work] in TysWiredIn.
      
      Of course, nothing is ever entirely simple. This one
      proved quite fiddly.
      
      - I did quite a bit of renaming, which makes this patch
        touch a lot of modules. In partiuclar tupleCon -> tupleDataCon.
      
      - I made constraint tuples known-key rather than wired-in.
        This is different to boxed/unboxed tuples, but it proved
        awkward to have all the superclass selectors wired-in.
        Easier just to use the standard mechanims.
      
      - While I was fiddling with known-key names, I split the TH Name
        definitions out of DsMeta into a new module THNames.  That meant
        that the known-key names can all be gathered in PrelInfo, without
        causing module loops.
      
      - I found that the parser was parsing an import item like
            T( .. )
        as a *data constructor* T, and then using setRdrNameSpace to
        fix it.  Stupid!  So I changed the parser to parse a *type
        constructor* T, which means less use of setRdrNameSpace.
      
        I also improved setRdrNameSpace to behave better on Exact Names.
        Largely on priciple; I don't think it matters a lot.
      
      - When compiling a data type declaration for a wired-in thing like
        tuples (,), or lists, we don't really need to look at the
        declaration.  We have the wired-in thing!  And not doing so avoids
        having to line up the uniques for data constructor workers etc.
        See Note [Declarations for wired-in things]
      
      - I found that FunDeps.oclose wasn't taking superclasses into
        account; easily fixed.
      
      - Some error message refactoring for invalid constraints in TcValidity
      130e93aa
  16. 12 May, 2015 2 commits
    • David Terei's avatar
      New handling of overlapping inst in Safe Haskell · 4fffbc34
      David Terei authored
      We do much better now due to the newish per-instance flags. Rather than
      mark any module that uses `-XOverlappingInstances`,
      `-XIncoherentInstances` or the new `OVERLAP*` pragmas as unsafe, we
      regard them all as safe and defer the check until an overlap occurs.
      
      An type-class method call that involves overlapping instances is
      considered _unsafe_ when:
      
      1) The most specific instance, Ix, is from a module marked `-XSafe`
      2) Ix is an orphan instance or a MPTC
      3) At least one instance that Ix overlaps, Iy, is:
         a) from a different module than Ix
         AND
         b) Iy is not marked `OVERLAPPABLE`
      
      This check is only enforced in modules compiled with `-XSafe` or
      `-XTrustworthy`.
      
      This fixes Safe Haskell to work with the latest overlapping instance
      pragmas, and also brings consistent behavior. Previously, Safe Inferred
      modules behaved differently than `-XSafe` modules.
      4fffbc34
    • David Terei's avatar
      Fix safe haskell bug: instances in safe-inferred · eecef173
      David Terei authored
      Instances in Safe Inferred modules weren't marked being marked as coming
      from a Safe module.
      eecef173
  17. 01 May, 2015 1 commit
  18. 23 Feb, 2015 1 commit
    • thomie's avatar
      Error out on `Main` without `main` in GHCi (#7765) · 0fa20726
      thomie authored
      Summary:
      GHC does 2 validation checks for module `Main`:
      * does `main` exist
      * is `main` exported (#414)
      
      The second check is done in ghc as well as in ghci (and runghc and ghc -e).
      The first check however is currently not done in ghci, to prevent "'main' is
      not in scope" errors when loading simple scripts. See commit d28ba8c8 for
      more information.
      
      This commit tightens the special case for ghci. When the file does not contain
      a main function, but does contain an explicit module header (i.e. "module Main
      where"), then /do/ raise an error in ghci (and runghc and ghc -e) as well
      
      Test Plan:
      module/T7765: a module Main with an explicit module header but without a
      main function should be an error for all Ways.
      
      Additionaly: delete test module/mod174. It was added in commit 5a54c38e, but it
      is a duplicate of module/T414.
      
      Reviewers: austin
      
      Reviewed By: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D649
      
      GHC Trac Issues: #7765
      0fa20726
  19. 05 Feb, 2015 1 commit
  20. 13 Jan, 2015 1 commit
    • GregWeber's avatar
      add -th-file which generates a th.hs file · 07ace5c2
      GregWeber authored
      Summary:
      see Trac #8624
      
      similar functionality is now available
      with -ddump-to-file -ddump-splices
      
      However, users are already accustomed to -ddump-splices
      having a particular format, and this format is not completely valid code
      The goal of -th-file is to dump valid Haskell code
      
      Additionally, the convention of -ddump-to-file is to name the file after
      the flag, so the file is .dump-splices
      Given that the goal of the new flag is to generate valid Haskell,
      The extension should be .hs
      
      Additionally, -ddump-to-file effects all other dump flags
      
      Test Plan:
      look at the output of using the -th-file flag
      and compare it to the output of using -ddump-to-file and -ddump-splices
      I want to add test cases, but just need some pointers on getting started there
      
      Reviewers: thomie, goldfire, simonpj, austin
      
      Reviewed By: simonpj, austin
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D518
      
      GHC Trac Issues: #8624
      07ace5c2
  21. 09 Jan, 2015 1 commit
  22. 06 Jan, 2015 3 commits
    • Simon Peyton Jones's avatar
    • Simon Peyton Jones's avatar
      Major patch to add -fwarn-redundant-constraints · 32973bf3
      Simon Peyton Jones authored
      The idea was promted by Trac #9939, but it was Christmas, so I did
      some recreational programming that went much further.
      
      The idea is to warn when a constraint in a user-supplied context is
      redundant.  Everything is described in detail in
        Note [Tracking redundant constraints]
      in TcSimplify.
      
      Main changes:
      
       * The new ic_status field in an implication, of type ImplicStatus.
         It replaces ic_insol, and includes information about redundant
         constraints.
      
       * New function TcSimplify.setImplicationStatus sets the ic_status.
      
       * TcSigInfo has sig_report_redundant field to say whenther a
         redundant constraint should be reported; and similarly
         the FunSigCtxt constructor of UserTypeCtxt
      
       * EvBinds has a field eb_is_given, to record whether it is a given
         or wanted binding. Some consequential chagnes to creating an evidence
         binding (so that we record whether it is given or wanted).
      
       * AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds;
         see Note [Typechecking plan for instance declarations] in
         TcInstDcls
      
       * Some significant changes to the type checking of instance
         declarations; Note [Typechecking plan for instance declarations]
         in TcInstDcls.
      
       * I found that TcErrors.relevantBindings was failing to zonk the
         origin of the constraint it was looking at, and hence failing to
         find some relevant bindings.  Easy to fix, and orthogonal to
         everything else, but hard to disentangle.
      
      Some minor refactorig:
      
       * TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds
      
       * TcClassDcl and TcInstDcls now have their own code for typechecking
         a method body, rather than sharing a single function. The shared
         function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code
         and the differences were growing confusing.
      
       * Add new function TcRnMonad.pushLevelAndCaptureConstraints, and
         use it
      
       * Add new function Bag.catBagMaybes, and use it in TcSimplify
      32973bf3
    • Simon Peyton Jones's avatar
      Make the location in TcLclEnv and CtLoc into a RealSrcSpan · d2b6e767
      Simon Peyton Jones authored
      Previously it was a SrcSpan, which can be an UnhelpulSrcSpan,
      but actually for TcLclEnv and CtLoc we always know it is
      a real source location, and it's good to make the types
      reflect that fact.
      
      There is a continuing slight awkwardness (not new with this
      patch) about what "file name" to use for GHCi code.  Current
      we say "<interactive>" which seems just about OK.
      d2b6e767
  23. 17 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Fix the scope-nesting for arrows · f50d62bb
      Simon Peyton Jones authored
      Previously we were capturing the *entire environment* when moving under
      a 'proc', for the newArrowScope/escapeArrowScope thing.  But that a blunderbuss,
      and in any case isn't right (the untouchable-type-varaible invariant gets
      invalidated).
      
      So I fixed it to be much more refined: just the LocalRdrEnv and constraints are
      captured.
      
      I think this is right; but if not we should just add more fields to ArrowCtxt,
      not return to the blunderbuss.
      
      This patch fixes the ASSERT failure in Trac #5267
      f50d62bb
  24. 12 Dec, 2014 1 commit
  25. 10 Dec, 2014 2 commits
  26. 03 Dec, 2014 1 commit
  27. 02 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Rename Untouchables to TcLevel · 26a3d0fe
      Simon Peyton Jones authored
      This is a long-overdue renaming
         Untouchables  -->   TcLevel
      It is renaming only; no change in functionality.
      
      We really wanted to get this done before the 7.10 fork.
      26a3d0fe
  28. 30 Nov, 2014 1 commit
    • Edward Z. Yang's avatar
      Filter instance visibility based on set of visible orphans, fixes #2182. · 4c834fdd
      Edward Z. Yang authored
      Summary:
      Amazingly, the fix for this very old bug is quite simple: when type-checking,
      maintain a set of "visible orphan modules" based on the orphans list of
      modules which we explicitly imported.  When we import an instance and it
      is an orphan, we check if it is in the visible modules set, and if not,
      ignore it.  A little bit of refactoring for when orphan-hood is calculated
      happens so that we always know if an instance is an orphan or not.
      
      For GHCi, we preinitialize the visible modules set based on the list of
      interactive imports which are active.
      
      Future work: Cache the visible orphan modules set for GHCi, rather than
      recomputing it every type-checking round.  (But it's tricky what to do when you
      /remove/ a module: you need a data structure a little more complicated than
      just a set of modules.)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: new tests and validate
      
      Reviewers: simonpj, austin
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D488
      
      GHC Trac Issues: #2182
      4c834fdd
  29. 28 Nov, 2014 3 commits
  30. 21 Nov, 2014 1 commit
    • Simon Peyton Jones's avatar
      Rejig builders for pattern synonyms, especially unlifted ones · e8762081
      Simon Peyton Jones authored
      When a pattern synonym is for an unlifted pattern, its "builder" would
      naturally be a top-level unlifted binding, which isn't allowed.  So we
      give it an extra Void# argument.
      
      Our Plan A involved then making *two* Ids for these builders, with
      some consequential fuss in the desugarer.  This was more pain than I
      liked, so I've re-jigged it.
      
       * There is just one builder for a pattern synonym.
      
       * It may have an extra Void# arg, but this decision is signalled
         by the Bool in the psBuilder field.
      
         I did the same for the psMatcher field.
      
         Both Bools are serialised into interface files, so there is
         absolutely no doubt whether that extra Void# argument is required.
      
       * I renamed "wrapper" to "builder".  We have too may "wrappers"
      
       * In order to deal with typecchecking occurrences of P in expressions,
         I refactored the tcInferId code in TcExpr.
      
      All of this allowed me to revert 5fe872
         "Apply compulsory unfoldings during desugaring, except for `seq` which is special."
      which turned out to be a rather messy hack in DsBinds
      e8762081
  31. 20 Nov, 2014 1 commit
  32. 19 Nov, 2014 1 commit
    • GregWeber's avatar
      make TcRnMonad.lhs respect -ddump-to-file · 33c029fa
      GregWeber authored
      Summary: allows things such as: -ddump-to-file -ddump-splices
      
      Test Plan:
      compile with flags -ddump-to-file -ddump-splices
      verify that it does output an extra file
      
      Try out other flags.
      I noticed that with -ddump-tc there is some output going to file and some to stdout.
      
      Reviewers: hvr, austin
      
      Reviewed By: austin
      
      Subscribers: simonpj, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D460
      
      GHC Trac Issues: #9126
      33c029fa