1. 04 Apr, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #2188: scoping in TH declarations quotes · a27c5f77
      simonpj@microsoft.com authored
      This patch fixes a rather tiresome issue, namely the fact that
      a TH declaration quote *shadows* bindings in outer scopes:
      
        f g = [d| f :: Int
                  f = g
        	    g :: Int
                  g = 4 |]
      
      Here, the outer bindings for 'f' (top-level) and 'g' (local)
      are shadowed, and the inner bindings for f,g should not be
      reported as duplicates.  (Remember they are top-level bindings.)
      
      The actual bug was that we'd forgotten to delete 'g' from the
      LocalRdrEnv, so the type sig for 'g' was binding to the outer
      'g' not the inner one.
      a27c5f77
  2. 03 Apr, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #2136: reporting of unused variables · 7502efdc
      simonpj@microsoft.com authored
      There's a bit of a hack RnBinds.rnValBindsAndThen, documented
      in Note [Unused binding hack].  But the hack was over brutal
      before, and produced unnecssarily bad (absence of) warnings.
      This patch does a bit of refactoring; and fixes the bug in
      rnValBindsAndThen.
      7502efdc
  3. 26 Feb, 2008 1 commit
  4. 07 Feb, 2008 1 commit
    • Ian Lynagh's avatar
      Convert more UniqFM's back to LazyUniqFM's · d51f42f6
      Ian Lynagh authored
      These fix these failures:
         break008(ghci)
         break009(ghci)
         break026(ghci)
         ghci.prog009(ghci)
         ghci025(ghci)
         print007(ghci)
         prog001(ghci)
         prog002(ghci)
         prog003(ghci)
      at least some of which have this symptom:
          Exception: expectJust prune
      d51f42f6
  5. 05 Feb, 2008 1 commit
  6. 24 Jan, 2008 1 commit
    • Ian Lynagh's avatar
      Fix the build · 6c7b41cc
      Ian Lynagh authored
      Work around various problems caused by some of the monadification patches
      not being applied.
      6c7b41cc
  7. 18 Jan, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Add quasi-quotation, courtesy of Geoffrey Mainland · f3399c44
      simonpj@microsoft.com authored
      This patch adds quasi-quotation, as described in
        "Nice to be Quoted: Quasiquoting for Haskell"
      	(Geoffrey Mainland, Haskell Workshop 2007)
      Implemented by Geoffrey and polished by Simon.
      
      Overview
      ~~~~~~~~
      The syntax for quasiquotation is very similar to the existing
      Template haskell syntax:
      	[$q| stuff |]
      where 'q' is the "quoter".  This syntax differs from the paper, by using
      a '$' rather than ':', to avoid clashing with parallel array comprehensions.
       
      The "quoter" is a value of type Language.Haskell.TH.Quote.QuasiQuoter, which
      contains two functions for quoting expressions and patterns, respectively.
       
           quote = Language.Haskell.TH.Quote.QuasiQuoter quoteExp quotePat
       
           quoteExp :: String -> Language.Haskell.TH.ExpQ
           quotePat :: String -> Language.Haskell.TH.PatQ
      
      TEXT is passed unmodified to the quoter. The context of the
      quasiquotation statement determines which of the two quoters is
      called: if the quasiquotation occurs in an expression context,
      quoteExp is called, and if it occurs in a pattern context, quotePat
      is called.
      
      The result of running the quoter on its arguments is spliced into
      the program using Template Haskell's existing mechanisms for
      splicing in code. Note that although Template Haskell does not
      support pattern brackets, with this patch binding occurrences of
      variables in patterns are supported. Quoters must also obey the same
      stage restrictions as Template Haskell; in particular, in this
      example quote may not be defined in the module where it is used as a
      quasiquoter, but must be imported from another module.
      
      Points to notice
      ~~~~~~~~~~~~~~~~
      * The whole thing is enabled with the flag -XQuasiQuotes
      
      * There is an accompanying patch to the template-haskell library. This
        involves one interface change:
      	currentModule :: Q String
        is replaced by
      	location :: Q Loc
        where Loc is a data type defined in TH.Syntax thus:
            data Loc
              = Loc { loc_filename :: String
      	      , loc_package  :: String
      	      , loc_module   :: String
      	      , loc_start    :: CharPos
      	      , loc_end      :: CharPos }
      
            type CharPos = (Int, Int)	-- Line and character position
       
        So you get a lot more info from 'location' than from 'currentModule'.
        The location you get is the location of the splice.
        
        This works in Template Haskell too of course, and lets a TH program
        generate much better error messages.
      
      * There's also a new module in the template-haskell package called 
        Language.Haskell.TH.Quote, which contains support code for the
        quasi-quoting feature.
      
      * Quasi-quote splices are run *in the renamer* because they can build 
        *patterns* and hence the renamer needs to see the output of running the
        splice.  This involved a bit of rejigging in the renamer, especially
        concerning the reporting of duplicate or shadowed names.
      
        (In fact I found and removed a few calls to checkDupNames in RnSource 
        that are redundant, becuase top-level duplicate decls are handled in
        RnNames.)
      
      
      f3399c44
  8. 14 Jan, 2008 1 commit
  9. 20 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Implement generalised list comprehensions · 67cb4091
      simonpj@microsoft.com authored
        This patch implements generalised list comprehensions, as described in 
        the paper "Comprehensive comprehensions" (Peyton Jones & Wadler, Haskell
        Workshop 2007).  If you don't use the new comprehensions, nothing
        should change.
        
        The syntax is not exactly as in the paper; see the user manual entry 
        for details.
        
        You need an accompanying patch to the base library for this stuff 
        to work.
        
        The patch is the work of Max Bolingbroke [batterseapower@hotmail.com], 
        with some advice from Simon PJ.
        
        The related GHC Wiki page is 
          http://hackage.haskell.org/trac/ghc/wiki/SQLLikeComprehensions 
      67cb4091
  10. 13 Dec, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Improve free-variable handling for rnPat and friends (fixes Trac #1972) · 7f2909e0
      simonpj@microsoft.com authored
      As well as fixing the immediate problem (Trac #1972) this patch does
      a signficant simplification and refactoring of pattern renaming.
      
      Fewer functions, fewer parameters passed....it's all good.  But it
      took much longer than I expected to figure out.
      
      The most significant change is that the NameMaker type does *binding*
      as well as *making* and, in the matchNameMaker case, checks for unused
      bindings as well.  This is much tider.
      
      (No need to merge to the 6.8 branch, but no harm either.)
      
      7f2909e0
  11. 10 Oct, 2007 1 commit
    • Dan Licata's avatar
      View patterns, record wildcards, and record puns · 6a05ec5e
      Dan Licata authored
      This patch implements three new features:
      * view patterns (syntax: expression -> pat in a pattern)
      * working versions of record wildcards and record puns
      See the manual for detailed descriptions.
      
      Other minor observable changes:
      * There is a check prohibiting local fixity declarations
        when the variable being fixed is not defined in the same let
      * The warn-unused-binds option now reports warnings for do and mdo stmts
      
      Implementation notes: 
      
      * The pattern renamer is now in its own module, RnPat, and the
      implementation is now in a CPS style so that the correct context is
      delivered to pattern expressions.
      
      * These features required a fairly major upheaval to the renamer.
      Whereas the old version used to collect up all the bindings from a let
      (or top-level, or recursive do statement, ...) and put them into scope
      before renaming anything, the new version does the collection as it
      renames.  This allows us to do the right thing with record wildcard
      patterns (which need to be expanded to see what names should be
      collected), and it allows us to implement the desired semantics for view
      patterns in lets.  This change had a bunch of domino effects brought on
      by fiddling with the top-level renaming.
      
      * Prior to this patch, there was a tricky bug in mkRecordSelId in HEAD,
      which did not maintain the invariant necessary for loadDecl.  See note
      [Tricky iface loop] for details.
      6a05ec5e
  12. 04 Sep, 2007 1 commit
  13. 03 Sep, 2007 1 commit
  14. 01 Sep, 2007 1 commit
  15. 09 Aug, 2007 1 commit
  16. 08 Jul, 2007 1 commit
  17. 21 Jun, 2007 1 commit
    • David Himmelstrup's avatar
      Add several new record features · 2eb04ca0
      David Himmelstrup authored
      1. Record disambiguation (-fdisambiguate-record-fields)
      
      In record construction and pattern matching (although not
      in record updates) it is clear which field name is intended
      even if there are several in scope.  This extension uses
      the constructor to disambiguate.  Thus
      	C { x=3 }
      uses the 'x' field from constructor C (assuming there is one)
      even if there are many x's in scope.
      
      
      2. Record punning (-frecord-puns)
      
      In a record construction or pattern match or update you can 
      omit the "=" part, thus
      	C { x, y }
      This is just syntactic sugar for
      	C { x=x, y=y }
      
      
      3.  Dot-dot notation for records (-frecord-dot-dot)
      
      In record construction or pattern match (but not update) 
      you can use ".." to mean "all the remaining fields".  So
      
      	C { x=v, .. }
      
      means to fill in the remaining fields to give
      
      	C { x=v, y=y }
      
      (assuming C has fields x and y).  This might reasonably
      considered very dodgy stuff.  For pattern-matching it brings
      into scope a bunch of things that are not explictly mentioned;
      and in record construction it just picks whatver 'y' is in
      scope for the 'y' field.   Still, Lennart Augustsson really
      wants it, and it's a feature that is extremely easy to explain.
      
      
      Implementation
      ~~~~~~~~~~~~~~
      I thought of using the "parent" field in the GlobalRdrEnv, but
      that's really used for import/export and just isn't right for this.
      For example, for import/export a field is a subordinate of the *type
      constructor* whereas here we need to know what fields belong to a
      particular *data* constructor.
      
      The main thing is that we need to map a data constructor to its
      fields, and we need to do so in the renamer.   For imported modules
      it's easy: just look in the imported TypeEnv.  For the module being
      compiled, we make a new field tcg_field_env in the TcGblEnv.
      The important functions are
      	RnEnv.lookupRecordBndr
      	RnEnv.lookupConstructorFields
      
      There is still a significant infelicity in the way the renamer
      works on patterns, which I'll tackle next.
      
      
      I also did quite a bit of refactoring in the representation of
      record fields (mainly in HsPat).***END OF DESCRIPTION***
      
      Place the long patch description above the ***END OF DESCRIPTION*** marker.
      The first line of this file will be the patch name.
      
      
      This patch contains the following changes:
      
      M ./compiler/deSugar/Check.lhs -3 +5
      M ./compiler/deSugar/Coverage.lhs -6 +7
      M ./compiler/deSugar/DsExpr.lhs -6 +13
      M ./compiler/deSugar/DsMeta.hs -8 +8
      M ./compiler/deSugar/DsUtils.lhs -1 +1
      M ./compiler/deSugar/MatchCon.lhs -2 +2
      M ./compiler/hsSyn/Convert.lhs -3 +3
      M ./compiler/hsSyn/HsDecls.lhs -9 +25
      M ./compiler/hsSyn/HsExpr.lhs -13 +3
      M ./compiler/hsSyn/HsPat.lhs -25 +63
      M ./compiler/hsSyn/HsUtils.lhs -3 +3
      M ./compiler/main/DynFlags.hs +6
      M ./compiler/parser/Parser.y.pp -13 +17
      M ./compiler/parser/RdrHsSyn.lhs -16 +18
      M ./compiler/rename/RnBinds.lhs -2 +2
      M ./compiler/rename/RnEnv.lhs -22 +82
      M ./compiler/rename/RnExpr.lhs -34 +12
      M ./compiler/rename/RnHsSyn.lhs -3 +2
      M ./compiler/rename/RnSource.lhs -50 +78
      M ./compiler/rename/RnTypes.lhs -50 +84
      M ./compiler/typecheck/TcExpr.lhs -18 +18
      M ./compiler/typecheck/TcHsSyn.lhs -20 +21
      M ./compiler/typecheck/TcPat.lhs -8 +6
      M ./compiler/typecheck/TcRnMonad.lhs -6 +15
      M ./compiler/typecheck/TcRnTypes.lhs -2 +11
      M ./compiler/typecheck/TcTyClsDecls.lhs -3 +4
      M ./docs/users_guide/flags.xml +7
      M ./docs/users_guide/glasgow_exts.xml +42
      2eb04ca0
  18. 20 Jun, 2007 1 commit
  19. 06 Jun, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Remove unnecessary free-variables from renamer · 3c4a732b
      simonpj@microsoft.com authored
      The renamer used to be responsible for making sure that all interfaces
      with instance decls (other than orphans) were loaded.  But TH makes that
      impossible, so the typechecker does it, via checkWiredInTyCon.
      
      This patch simply removes redundant additions to the free-variable set
      in the renamer, which were there, I believe, solely to ensure that the 
      instances came in.  Removing them should change nothing, but it's a 
      useful clean up.
      3c4a732b
  20. 02 May, 2007 1 commit
  21. 23 Mar, 2007 1 commit
  22. 04 Feb, 2007 1 commit
  23. 21 Dec, 2006 1 commit
    • lennart@augustsson.net's avatar
      Add support for overloaded string literals. · 90dc9026
      lennart@augustsson.net authored
      The class is named IsString with the single method fromString.
      Overloaded strings work the same way as overloaded numeric literals.
      In expressions a string literals gets a fromString applied to it.
      In a pattern there will be an equality comparison with the fromString:ed literal.
      
      Use -foverloaded-strings to enable this extension.
       
      90dc9026
  24. 29 Dec, 2006 1 commit
    • andy@galois.com's avatar
      Adding a GENERATED pragma · d386e0d2
      andy@galois.com authored
      Adding a {-# GENERATED "SourceFile" SourceSpan #-} <expr> pragma.
      This will be used to generate coverage for tool generated (or quoted) code.
      The pragma states the the expression was generated/quoted from the stated
      source file and source span.
      d386e0d2
  25. 10 Dec, 2006 1 commit
  26. 13 Oct, 2006 1 commit
    • simonpj@microsoft.com's avatar
      More refactoring in RnNames · 5ad61e14
      simonpj@microsoft.com authored
      I rather self-indulgently spent a chunk of yesterday working on 
      refactoring RnNames further.  The result is significantly simpler:
      
      * A GlobalRdrElt gets an extra field, gre_par, which records
        the parent (if any) of the name
      
      * ImportAvails has two fields deleted: imp_env and imp_parent.
        The information provided by these fields was only used when
        processing the export list; and the same information is now readily
        generated from the GlobalRdrElts in the GlobalRdrEnv
      
      I also did some tidying up; notably moving AvailEnv stuff from
      TcRnTypes to RnNames.
      
      The result is tha the compiler is some 130 lines shorter than before
      5ad61e14
  27. 11 Oct, 2006 1 commit
    • Simon Marlow's avatar
      Interface file optimisation and removal of nameParent · b00b5bc0
      Simon Marlow authored
      This large commit combines several interrelated changes:
      
        - IfaceSyn now contains actual Names rather than the special
          IfaceExtName type.  The binary interface file contains
          a symbol table of Names, where each entry is a (package,
          ModuleName, OccName) triple.  Names in the IfaceSyn point
          to entries in the symbol table.
      
          This reduces the size of interface files, which should
          hopefully improve performance (not measured yet).
      
          The toIfaceXXX functions now do not need to pass around
          a function from Name -> IfaceExtName, which makes that
          code simpler.
      
        - Names now do not point directly to their parents, and the
          nameParent operation has gone away.  It turned out to be hard to
          keep this information consistent in practice, and the parent info
          was only valid in some Names.  Instead we made the following
          changes:
      
          * ImportAvails contains a new field 
                imp_parent :: NameEnv AvailInfo
            which gives the family info for any Name in scope, and
            is used by the renamer when renaming export lists, amongst
            other things.  This info is thrown away after renaming.
      
          * The mi_ver_fn field of ModIface now maps to
            (OccName,Version) instead of just Version, where the
            OccName is the parent name.  This mapping is used when
            constructing the usage info for dependent modules.
            There may be entries in mi_ver_fn for things that are not in
            scope, whereas imp_parent only deals with in-scope things.
      
          * The md_exports field of ModDetails now contains
            [AvailInfo] rather than NameSet.  This gives us
            family info for the exported names of a module.
      
      Also:
      
         - ifaceDeclSubBinders moved to IfaceSyn (seems like the
           right place for it).
      
         - heavily refactored renaming of import/export lists.
      
         - Unfortunately external core is now broken, as it relied on
           IfaceSyn.  It requires some attention.
      b00b5bc0
  28. 03 Oct, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Fix scoped type variables for expression type signatures · 9da46390
      simonpj@microsoft.com authored
      I had forgotten to bring scoped type variables into scope at an expression
      type signature, such as
      	e :: forall s. <type>
      where 's' should scope over the expression e.
      
      Like everything to do with scoped type variables, fixing this took an 
      unreasonable amount of work.  I'm sure there must be a better way to 
      achitect this!
      
      I updated the user manual too.
      
      A test is tc213.
      
      It would be good to push this into 6.6.1
      9da46390
  29. 29 Sep, 2006 1 commit
  30. 23 Sep, 2006 1 commit
  31. 04 Aug, 2006 1 commit
  32. 07 Sep, 2006 1 commit
  33. 25 Aug, 2006 1 commit
  34. 08 Aug, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Remove srcSpanStartLine/srcSpanEndLine crash · e944b32b
      simonpj@microsoft.com authored
      srcSpanStartLine/srcSpanEndLine panic on UnhelpfulLoc. They should not
      really be exported by SrcLoc at all, but unfortunately they are used in
      Lexer.x, which knows enough to avoid the panic.
      
      However the call in RnEnv didn't know, and the panic was triggered 
      by Template Haskell spliced code.  This patch fixes it by exporting
      the predicate RnEnv wanted, namely isOneLineSpan.
      e944b32b
  35. 04 Aug, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Do pre-subsumption in the main subsumption check · af20907a
      simonpj@microsoft.com authored
      This patch improves the subsumption check (in TcUnify.tc_sub) so that
      it does pre-subsumption first.  The key code is in the case with
      guard (isSigmaTy actual_ty); note the new call to preSubType.
      
      Shorn of details, the question is this.  Should this hold?
      
      	forall a. a->a   <=   Int -> (forall b. Int)
      
      Really, it should; just instantiate 'a' to Int.  This is just what
      the pre-subsumption phase (which used in function applications),
      will do.
      
      I did a bit of refactoring to achieve this.
      
      Fixes Trac #821.  Test tc205 tests.
      af20907a
  36. 25 Jul, 2006 1 commit
    • Simon Marlow's avatar
      Generalise Package Support · 61d2625a
      Simon Marlow authored
      This patch pushes through one fundamental change: a module is now
      identified by the pair of its package and module name, whereas
      previously it was identified by its module name alone.  This means
      that now a program can contain multiple modules with the same name, as
      long as they belong to different packages.
      
      This is a language change - the Haskell report says nothing about
      packages, but it is now necessary to understand packages in order to
      understand GHC's module system.  For example, a type T from module M
      in package P is different from a type T from module M in package Q.
      Previously this wasn't an issue because there could only be a single
      module M in the program.
      
      The "module restriction" on combining packages has therefore been
      lifted, and a program can contain multiple versions of the same
      package.
      
      Note that none of the proposed syntax changes have yet been
      implemented, but the architecture is geared towards supporting import
      declarations qualified by package name, and that is probably the next
      step.
      
      It is now necessary to specify the package name when compiling a
      package, using the -package-name flag (which has been un-deprecated).
      Fortunately Cabal still uses -package-name.
      
      Certain packages are "wired in".  Currently the wired-in packages are:
      base, haskell98, template-haskell and rts, and are always referred to
      by these versionless names.  Other packages are referred to with full
      package IDs (eg. "network-1.0").  This is because the compiler needs
      to refer to entities in the wired-in packages, and we didn't want to
      bake the version of these packages into the comiler.  It's conceivable
      that someone might want to upgrade the base package independently of
      GHC.
      
      Internal changes:
      
        - There are two module-related types:
      
              ModuleName      just a FastString, the name of a module
              Module          a pair of a PackageId and ModuleName
      
          A mapping from ModuleName can be a UniqFM, but a mapping from Module
          must be a FiniteMap (we provide it as ModuleEnv).
      
        - The "HomeModules" type that was passed around the compiler is now
          gone, replaced in most cases by the current package name which is
          contained in DynFlags.  We can tell whether a Module comes from the
          current package by comparing its package name against the current
          package.
      
        - While I was here, I changed PrintUnqual to be a little more useful:
          it now returns the ModuleName that the identifier should be qualified
          with according to the current scope, rather than its original
          module.  Also, PrintUnqual tells whether to qualify module names with
          package names (currently unused).
      
      Docs to follow.
      61d2625a
  37. 02 May, 2006 1 commit
  38. 07 Apr, 2006 1 commit
    • Simon Marlow's avatar
      Reorganisation of the source tree · 0065d5ab
      Simon Marlow authored
      Most of the other users of the fptools build system have migrated to
      Cabal, and with the move to darcs we can now flatten the source tree
      without losing history, so here goes.
      
      The main change is that the ghc/ subdir is gone, and most of what it
      contained is now at the top level.  The build system now makes no
      pretense at being multi-project, it is just the GHC build system.
      
      No doubt this will break many things, and there will be a period of
      instability while we fix the dependencies.  A straightforward build
      should work, but I haven't yet fixed binary/source distributions.
      Changes to the Building Guide will follow, too.
      0065d5ab
  39. 06 Apr, 2006 1 commit
  40. 02 Mar, 2006 1 commit