1. 12 Nov, 2014 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #9066. · d782694f
      eir@cis.upenn.edu authored
      When splicing in a fixity declaration, look for both term-level things
      and type-level things. This requires some changes elsewhere in the
      code to allow for more flexibility when looking up Exact names, which
      can be assigned the wrong namespace during fixity declaration
      conversion.
      
      See the ticket for more info.
      d782694f
  2. 21 Jul, 2014 1 commit
    • Edward Z. Yang's avatar
      Rename PackageId to PackageKey, distinguishing it from Cabal's PackageId. · 4bebab25
      Edward Z. Yang authored
      Summary:
      Previously, both Cabal and GHC defined the type PackageId, and we expected
      them to be roughly equivalent (but represented differently).  This refactoring
      separates these two notions.
      
      A package ID is a user-visible identifier; it's the thing you write in a
      Cabal file, e.g. containers-0.9.  The components of this ID are semantically
      meaningful, and decompose into a package name and a package vrsion.
      
      A package key is an opaque identifier used by GHC to generate linking symbols.
      Presently, it just consists of a package name and a package version, but
      pursuant to #9265 we are planning to extend it to record other information.
      Within a single executable, it uniquely identifies a package.  It is *not* an
      InstalledPackageId, as the choice of a package key affects the ABI of a package
      (whereas an InstalledPackageId is computed after compilation.)  Cabal computes
      a package key for the package and passes it to GHC using -package-name (now
      *extremely* misnamed).
      
      As an added bonus, we don't have to worry about shadowing anymore.
      
      As a follow on, we should introduce -current-package-key having the same role as
      -package-name, and deprecate the old flag.  This commit is just renaming.
      
      The haddock submodule needed to be updated.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, simonmar, hvr, austin
      
      Subscribers: simonmar, relrod, carter
      
      Differential Revision: https://phabricator.haskell.org/D79
      
      Conflicts:
      	compiler/main/HscTypes.lhs
      	compiler/main/Packages.lhs
      	utils/haddock
      4bebab25
  3. 12 Jun, 2014 1 commit
    • Simon Peyton Jones's avatar
      Fix elemLocalRdrEnv (Trac #9160) · b637585d
      Simon Peyton Jones authored
      This was pretty obscure.  elemLocalRdrEnv was utterly wrong (replied
      False when it should reply True) when given an Exact Name. That
      doesn't happen often, but it does happen in the result of a TH splice.
      The result was that an associated type didn't get a type variable that
      lined up with its parent class (elemLocalRdrEnv is used in
      RnTypes.bindHsTyVars), and that messed up the singletons package.
      
      I've made a completely different test case to show up the bug:
      indexed_types/should_fail/T9160
      
      I also refactored RdrName.LocalRdrEnv to be a record with named
      fields, which makes the code more robust and easy to understand.
      b637585d
  4. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
      23892440
  5. 13 Feb, 2014 1 commit
  6. 09 Jan, 2014 1 commit
    • Simon Peyton Jones's avatar
      Re-work the naming story for the GHCi prompt (Trac #8649) · 73c08ab1
      Simon Peyton Jones authored
      The basic idea here is simple, and described in Note [The interactive package]
      in HscTypes, which starts thus:
      
          Note [The interactive package]
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          Type and class declarations at the command prompt are treated as if
          they were defined in modules
             interactive:Ghci1
             interactive:Ghci2
             ...etc...
          with each bunch of declarations using a new module, all sharing a
          common package 'interactive' (see Module.interactivePackageId, and
          PrelNames.mkInteractiveModule).
      
          This scheme deals well with shadowing.  For example:
      
             ghci> data T = A
             ghci> data T = B
             ghci> :i A
             data Ghci1.T = A  -- Defined at <interactive>:2:10
      
          Here we must display info about constructor A, but its type T has been
          shadowed by the second declaration.  But it has a respectable
          qualified name (Ghci1.T), and its source location says where it was
          defined.
      
          So the main invariant continues to hold, that in any session an original
          name M.T only refers to oe unique thing.  (In a previous iteration both
          the T's above were called :Interactive.T, albeit with different uniques,
          which gave rise to all sorts of trouble.)
      
      This scheme deals nicely with the original problem.  It allows us to
      eliminate a couple of grotseque hacks
        - Note [Outputable Orig RdrName] in HscTypes
        - Note [interactive name cache] in IfaceEnv
      (both these comments have gone, because the hacks they describe are no
      longer necessary). I was also able to simplify Outputable.QueryQualifyName,
      so that it takes a Module/OccName as args rather than a Name.
      
      However, matters are never simple, and this change took me an
      unreasonably long time to get right.  There are some details in
      Note [The interactive package] in HscTypes.
      73c08ab1
  7. 03 Jan, 2014 1 commit
    • Simon Peyton Jones's avatar
      Refactor the way shadowing in handled in GHCi · 5dffb4ac
      Simon Peyton Jones authored
      If you say
        ghci> import Foo( T )
        ghci> data T = MkT
        ghci> data T = XXX
      then the second 'data T' should shadow the first.  But the qualified
      Foo.T should still be available.  We really weren't handling this
      correctly at all, resulting in Trac #8639 and #8628 among others
      
      This patch:
      
      * Add RdrName.extendGlobalRdrEnv, which does shadowing properly
      
      * Change HscTypes.icExtendGblRdrEnv (was badly-named icPlusGblRdrEnv)
        to use the new function
      
      * Change RnNames.extendGobalRdrEnvRn to use the new function
      
      * Move gresFrom Avails into RdrName
      * Better pprGlobalRdrEnv function in RdrName
      5dffb4ac
  8. 22 Nov, 2013 1 commit
    • Simon Peyton Jones's avatar
      A raft of changes driven by Trac #8540 · 78814882
      Simon Peyton Jones authored
      The root cause of #8450 is that the new Template Haskell story, with
      the renamer doing more of the work of Template Haskell, wasn't dealing
      correctly with the keepAlive problem.  Consider
          g = ..blah...
          f = [| g |]
      Then f's RHS refers to g's name but not to g, so g was being discarded
      as dead code.
      
      Fixing this sucked me into a deep swamp of understanding how all the moving
      parts of hte new Template Haskell fit together, leading to a large collection
      of related changes and better documentation.  Specifically:
      
      * Instead of putting the TH level of a binder in the LocalRdrEnv, there
        is now a separate field
            tcl_th_bndrs :: NameEnv (TopLevelFlag, ThLevel)
        in the TcLclEnv, which records for each binder
           a) whether it is syntactically a top-level binder or not
           b) its TH level
        This deals uniformly with top-level and non-top-level binders, which was
        previously dealt with via greviously-delicate meddling with Internal and
        External Names.  Much better.
      
      * As a result I could remove the tct_level field of ATcId.
      
      * There are consequential changes in TcEnv too, which must also extend the
        level bindings.  Again, more clarity.
      
        I renamed TcEnv.tcExtendTcTyThingEnv to tcExtendKindEnv2, since it's only used
        during kind inference, for (AThing kind) and APromotionErr; and that is
        relevant to whether we want to extend the tcl_th_bndrs field (no).
      
      * I de-crufted the code in RnEnv.extendGlobalRdrEnv, by getting rid of the
        qual_gre code which said "Seems like 5 times as much work as it deserves!".
        Instead, RdrName.pickGREs makes the Internal names shadow External ones.
      
      * I moved the checkThLocalName cross-stage test to finishHsVar; previously
        we weren't doing the test at all in the OpApp case!
      
      * Quite a few changes (shortening the code) in the cross-stage checking code
        in TcExpr and RnSplice, notably to move the keepAlive call to the renamer
      
      One leftover piece:
      
      * In TcEnv I removed tcExtendGhciEnv and refactored
        tcExtendGlobalTyVars; this is really related to the next commit, but
        it was too hard to disentangle.
      78814882
  9. 04 Oct, 2013 1 commit
  10. 28 Jul, 2013 1 commit
  11. 14 Feb, 2013 1 commit
  12. 21 Aug, 2012 1 commit
  13. 12 Jun, 2012 1 commit
  14. 30 Mar, 2012 1 commit
  15. 28 Mar, 2012 1 commit
  16. 24 Mar, 2012 1 commit
  17. 23 Dec, 2011 1 commit
  18. 19 Dec, 2011 1 commit
    • Simon Peyton Jones's avatar
      Tidy up pretty-printing for variables · c492e50b
      Simon Peyton Jones authored
      We already have a class OutputableBndr; this patch adds
      methods pprInfixOcc and pprPrefixOcc, so that we can get
      rid of the hideous hack (the old) Outputable.pprHsVar.
      
      The hack was exposed by Trac #5657, which is thereby fixed.
      c492e50b
  19. 11 Nov, 2011 1 commit
    • dreixel's avatar
      New kind-polymorphic core · 09015be8
      dreixel authored
      This big patch implements a kind-polymorphic core for GHC. The current
      implementation focuses on making sure that all kind-monomorphic programs still
      work in the new core; it is not yet guaranteed that kind-polymorphic programs
      (using the new -XPolyKinds flag) will work.
      
      For more information, see http://haskell.org/haskellwiki/GHC/Kinds
      09015be8
  20. 04 Nov, 2011 1 commit
  21. 21 Sep, 2011 1 commit
    • Simon Marlow's avatar
      Add support for all top-level declarations to GHCi · 3db75724
      Simon Marlow authored
        This is work mostly done by Daniel Winograd-Cort during his
        internship at MSR Cambridge, with some further refactoring by me.
      
      This commit adds support to GHCi for most top-level declarations that
      can be used in Haskell source files.  Class, data, newtype, type,
      instance are all supported, as are Type Family-related declarations.
      
      The current set of declarations are shown by :show bindings.  As with
      variable bindings, entities bound by newer declarations shadow earlier
      ones.
      
      Tests are in testsuite/tests/ghci/scripts/ghci039--ghci054.
      Documentation to follow.
      3db75724
  22. 02 Sep, 2011 1 commit
  23. 22 Aug, 2011 1 commit
    • Simon Peyton Jones's avatar
      A batch of changes related to the handling of binders in instance decls · f76f0d0e
      Simon Peyton Jones authored
      The issue is that in
          instnace C T where
            data S = ...
            f = ...
      neither S nor f is really a binder; they are *occurrences*.  Moreover
      Haskell dictates that these particular occurrences are disambiguated
      by looking at the class whose instance they occur in.
      
      Some of this was not handled right for associated types.  And
      RnNames.getLocalNonValBinders was a bit messhy; this patch tidies it
      up.
      
      (And thenM is finally gone from RnSource.)
      f76f0d0e
  24. 05 Aug, 2011 2 commits
  25. 02 Aug, 2011 2 commits
    • Simon Peyton Jones's avatar
      78976235
    • Simon Peyton Jones's avatar
      Refactor the imports of InteractiveContext · 35d213ab
      Simon Peyton Jones authored
      Instead of two fields
         ic_toplev_scope :: [Module]
         ic_imports      :: [ImportDecl RdrName]
      
      we now just have one
         ic_imports :: [InteractiveImport]
      with the auxiliary data type
         data InteractiveImport
          = IIDecl (ImportDecl RdrName)  -- Bring the exports of a particular module
          	   	       		   -- (filtered by an import decl) into scope
      
          | IIModule Module	-- Bring into scope the entire top-level envt of
          	     		-- of this module, including the things imported
      			-- into it.
      
      This makes lots of code less confusing.  No change in behaviour.
      It's preparatory to fixing Trac #5147.
      
      While I was at I also
        * Cleaned up the handling of the "implicit" Prelude import
          by adding a ideclImplicit field to ImportDecl.  This
          significantly reduces plumbing in the handling of
          the implicit Prelude import
      
        * Used record notation consistently for ImportDecl
      35d213ab
  26. 11 Jun, 2011 1 commit
    • Simon Peyton Jones's avatar
      Fix tracking of what RdrNames are used (fixes Trac #5211) · 6f60f1f5
      Simon Peyton Jones authored
      The issue here was: what import declaration brings into
      scope the 'op here
      
         import qualified Foo( op )
         import Bar( C(op) )
         instance C Int where
           op = ...
      
      Well, the import of Bar, obviously.  But what if the
      import Bar had been
         import Bar( C )
      Then the instance is still supposed to work, getting
      op from the Foo.op imported from Foo.  (I'm assuming its
      the same op, of course.)
      6f60f1f5
  27. 09 Jun, 2011 1 commit
    • Ian Lynagh's avatar
      Refactor SrcLoc and SrcSpan · b2bd63f9
      Ian Lynagh authored
      The "Unhelpful" cases are now in a separate type. This allows us to
      improve various things, e.g.:
      * Most of the panic's in SrcLoc are now gone
      * The Lexer now works with RealSrcSpans rather than SrcSpans, i.e. it
        knows that it has real locations and thus can assume that the line
        number etc really exists
      * Some of the more suspicious cases are no longer necessary, e.g.
        we no longer need this case in advanceSrcLoc:
            advanceSrcLoc loc _ = loc -- Better than nothing
      
      More improvements can probably be made, e.g. tick locations can
      probably use RealSrcSpans too.
      b2bd63f9
  28. 22 Dec, 2010 1 commit
  29. 01 Jul, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix second bug in Trac #4127 · 2c183f9b
      simonpj@microsoft.com authored
      This bug concerned the awkward shadowing we do for 
      Template Haskell declaration brackets.  Lots of
      comments in 
      
        Note [Top-level Names in Template Haskell decl quotes]
      2c183f9b
  30. 25 May, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Refactor (again) the handling of default methods · 78693246
      simonpj@microsoft.com authored
      This patch fixes Trac #4056, by 
      
       a) tidying up the treatment of default method names
       b) removing the 'module' argument to newTopSrcBinder
      
      The details aren't that interesting, but the result
      is much tidier. The original bug was a 'nameModule' panic,
      caused by trying to find the module of a top-level name.
      But TH quotes generate Internal top-level names that don't
      have a module, and that is generally a good thing.  
      
      Fixing that in turn led to the default-method refactoring,
      which also makes the Name for a default method be handled
      in the same way as other derived names, generated in BuildTyCl
      via a call newImplicitBinder.  Hurrah.
      78693246
  31. 30 Mar, 2010 1 commit
  32. 04 Dec, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Use addToUFM_Acc where appropriate · 65277a1c
      simonpj@microsoft.com authored
      This way of extending a UniqFM has existed for some time, but
      we weren't really using it.
      
      addToUFM_Acc	:: Uniquable key =>
      			      (elt -> elts -> elts)	-- Add to existing
      			   -> (elt -> elts)		-- New element
      			   -> UniqFM elts 		-- old
      			   -> key -> elt 		-- new
      			   -> UniqFM elts		-- result
      65277a1c
  33. 20 Aug, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Improvements to record puns, wildcards · d64022dc
      simonpj@microsoft.com authored
      * Make C { A.a } work with punning, expanding to C { A.a = a }
      
      * Make it so that, with -fwarn-unused-matches, 
              f (C {..}) = x
        does not complain about the bindings introduced by the "..".
      
      * Make -XRecordWildCards implies -XDisambiguateRecordFields.
      
      * Overall refactoring of RnPat, which had become very crufty. 
        In particular, there is now a monad, CpsRn, private to RnPat,
        which deals with the cps-style plumbing.  This is why so many
        lines of RnPat have changed.
      
      * Refactor the treatment of renaming of record fields into two passes
      	- rnHsRecFields1, used both for patterns and expressions,
      	     which expands puns, wild-cards
        	- a local renamer in RnPat for fields in patterns
      	- a local renamer in RnExpr for fields in construction and update
        This make it all MUCH easier to understand
       
      * Improve documentation of record puns, wildcards, and disambiguation
      d64022dc
  34. 17 Jul, 2009 1 commit
  35. 28 May, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Improve printing of Orig RdrNames · 30ced404
      simonpj@microsoft.com authored
      In Tempate Haskell -ddump-splices, the "after" expression is populated 
      with RdrNames, many of which are Orig things.  We used to print these
      fully-qualified, but that's a bit heavy.
      
      This patch refactors the code a bit so that the same print-unqualified
      mechanism we use for Names also works for RdrNames.  Lots of comments
      too, because it took me a while to figure out how it all worked again.
      30ced404
  36. 28 Oct, 2008 1 commit
  37. 03 Oct, 2008 2 commits
    • simonpj@microsoft.com's avatar
      Expunge ThFake, cure Trac #2632 · 08a9d734
      simonpj@microsoft.com authored
      This patch fixes a dirty hack (the fake ThFake module), which in turn
      was causing Trac #2632.
      
      The new scheme is that the top-level binders in a TH [d| ... |] decl splice
      get Internal names.  That breaks a previous invariant that things like
      TyCons always have External names, but these TyCons are never long-lived;
      they live only long enough to typecheck the TH quotation; the result is
      discarded.  So it seems cool.
      
      Nevertheless -- Template Haskell folk: please test your code.  The testsuite
      is OK but it's conceivable that I've broken something in TH.  Let's see.
      08a9d734
    • simonpj@microsoft.com's avatar
      Add ASSERTs to all calls of nameModule · 66579ff9
      simonpj@microsoft.com authored
      nameModule fails on an InternalName.  These ASSERTS tell you
      which call failed.
      66579ff9