1. 04 May, 2011 1 commit
    • dreixel's avatar
      Remove HsNumTy and TypePati. · fed25228
      dreixel authored
      They belonged to the old generic deriving mechanism, so they can go. Adapted a lot of code as a consequence.
      fed25228
  2. 23 Sep, 2010 1 commit
  3. 18 Sep, 2010 1 commit
  4. 24 Jul, 2010 1 commit
  5. 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
  6. 12 Apr, 2010 1 commit
  7. 04 Mar, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Refactor part of the renamer to fix Trac #3901 · f1cc3eb9
      simonpj@microsoft.com authored
      This one was bigger than I anticipated!  The problem was that were
      were gathering the binders from a pattern before renaming -- but with
      record wild-cards we don't know what variables are bound by C {..}
      until after the renamer has filled in the "..".
      
      So this patch does the following
      
      * Change all the collect-X-Binders functions in HsUtils so that
        they expect to only be called *after* renaming.  That means they
        don't need to return [Located id] but just [id].  Which turned out
        to be a very worthwhile simplification all by itself.
      
      * Refactor the renamer, and in ptic RnExpr.rnStmt, so that it
        doesn't need to use collectLStmtsBinders on pre-renamed Stmts.
      
      * This in turn required me to understand how GroupStmt and
        TransformStmts were renamed.  Quite fiddly. I rewrote most of it;
        result is much shorter.
      
      * In doing so I flattened HsExpr.GroupByClause into its parent
        GroupStmt, with trivial knock-on effects in other files.
      
      Blargh.
      f1cc3eb9
  8. 10 Feb, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Several TH/quasiquote changes · 6f8ff0bb
      simonpj@microsoft.com authored
      a) Added quasi-quote forms for
            declarations
            types
         e.g.   f :: [$qq| ... |]
      
      b) Allow Template Haskell pattern quotes (but not splices)
         e.g.  f x = [p| Int -> $x |]
      
      c) Improve pretty-printing for HsPat to remove superfluous
         parens.  (This isn't TH related really, but it affects
         some of the same code.)
      
      
      A consequence of (a) is that when gathering and grouping declarations
      in RnSource.findSplice, we must expand quasiquotes as we do so.
      Otherwise it's all fairly straightforward.  I did a little bit of
      refactoring in TcSplice.
      
      User-manual changes still to come.
      6f8ff0bb
  9. 20 Jan, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3813: unused variables in GHCi bindings · 85f969a6
      simonpj@microsoft.com authored
      In a GHCi stmt we don't want to report unused variables, 
      because we don't know the scope of the binding, eg
      
      	Prelude> x <- blah
      
      Fixing this needed a little more info about the context of the stmt,
      thus the new constructor GhciStmt in the HsStmtContext type.
      85f969a6
  10. 05 Nov, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #3640, plus associated refactoring · df8b00e0
      simonpj@microsoft.com authored
      In fixing this bug (to do with record puns), I had the usual rush of
      blood to the head, and I did quite a bit of refactoring in the way
      that duplicate/shadowed names are reported.
      
      I think the result is shorter as well as clearer.
      
      In one place I found it convenient for the renamer to use the ErrCtxt
      carried in the monad.  (The renamer used not to have such a context,
      but years ago the typechecker and renamer monads became one, so now it
      does.)   So now it's availble if you want it in future.
      df8b00e0
  11. 21 Aug, 2009 1 commit
  12. 20 Aug, 2009 2 commits
    • simonpj@microsoft.com's avatar
      Wibble to RnPat refactoring · 18b8ff4f
      simonpj@microsoft.com authored
      18b8ff4f
    • 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
  13. 10 Sep, 2008 1 commit
  14. 26 Aug, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Fix flaggery for RULES (cf Trac #2497) · 24b1e136
      simonpj@microsoft.com authored
      This patch executes the plan described in the discussion in Trac #2497.
      Specficially:
      
          * Inside a RULE, switch on the forall-as-keyword in the lexer,
            unconditionally. (Actually this is done by an earlier patch.)
      
          * Merge the -XScopedTypeVariables and -XPatternSignatures flags,
            and deprecate the latter. Distinguishing them isn't senseless,
            but it's jolly confusing.
      
          * Inside a RULE, switch on -XScopedTypeVariables unconditionally. 
      
          * Change -frewrite-rules to -fenable-rewrite-rules; deprecate the former. 
            Internally the DynFlag is now Opt_EnableRewriteRules.
      
      There's a test in typecheck/should_compile/T2497.hs
      24b1e136
  15. 20 Jul, 2008 1 commit
  16. 16 Jun, 2008 1 commit
    • Ian Lynagh's avatar
      More commandline flag improvements · 0f5e104c
      Ian Lynagh authored
      * Allow -ffoo flags to be deprecated
      * Mark some -ffoo flags as deprecated
      * Avoid using deprecated flags in error messages, in the build system, etc
      * Add a flag to en/disable the deprecated flag warning
      0f5e104c
  17. 06 May, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Fix Trac #2246; overhaul handling of overloaded literals · ecdaf6bc
      simonpj@microsoft.com authored
      The real work of fixing Trac #2246 is to use shortCutLit in
      MatchLit.dsOverLit, so that type information discovered late in the
      day by the type checker can still be exploited during desugaring.
      
      However, as usual I found myself doing some refactoring along the
      way, to tidy up the handling of overloaded literals.   The main
      change is to split HsOverLit into a record, which in turn uses
      a sum type for the three variants.  This makes the code significantly
      more modular.
      
      data HsOverLit id
        = OverLit {
      	ol_val :: OverLitVal, 
      	ol_rebindable :: Bool,		-- True <=> rebindable syntax
      					-- False <=> standard syntax
      	ol_witness :: SyntaxExpr id,	-- Note [Overloaded literal witnesses]
      	ol_type :: PostTcType }
      
      data OverLitVal
        = HsIntegral   !Integer   	-- Integer-looking literals;
        | HsFractional !Rational   	-- Frac-looking literals
        | HsIsString   !FastString 	-- String-looking literals
      ecdaf6bc
  18. 04 May, 2008 1 commit
  19. 03 May, 2008 1 commit
  20. 12 Apr, 2008 1 commit
  21. 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
  22. 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
  23. 29 Mar, 2008 1 commit
  24. 07 Feb, 2008 2 commits
  25. 17 Jan, 2008 1 commit
  26. 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
  27. 17 Jan, 2008 1 commit
    • Isaac Dupree's avatar
      lots of portability changes (#1405) · 206b4dec
      Isaac Dupree authored
      re-recording to avoid new conflicts was too hard, so I just put it
      all in one big patch :-(  (besides, some of the changes depended on
      each other.)  Here are what the component patches were:
      
      Fri Dec 28 11:02:55 EST 2007  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * document BreakArray better
      
      Fri Dec 28 11:39:22 EST 2007  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * properly ifdef BreakArray for GHCI
      
      Fri Jan  4 13:50:41 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * change ifs on __GLASGOW_HASKELL__ to account for... (#1405)
        for it not being defined. I assume it being undefined implies
        a compiler with relatively modern libraries but without most
        unportable glasgow extensions.
      
      Fri Jan  4 14:21:21 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * MyEither-->EitherString to allow Haskell98 instance
      
      Fri Jan  4 16:13:29 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * re-portabilize Pretty, and corresponding changes
      
      Fri Jan  4 17:19:55 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * Augment FastTypes to be much more complete
      
      Fri Jan  4 20:14:19 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * use FastFunctions, cleanup FastString slightly
      
      Fri Jan  4 21:00:22 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * Massive de-"#", mostly Int# --> FastInt (#1405)
      
      Fri Jan  4 21:02:49 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * miscellaneous unnecessary-extension-removal
      
      Sat Jan  5 19:30:13 EST 2008  Isaac Dupree <id@isaac.cedarswampstudios.org>
        * add FastFunctions
      206b4dec
  28. 13 Dec, 2007 2 commits
  29. 01 Nov, 2007 1 commit
  30. 27 Oct, 2007 1 commit
    • simonpj@microsoft.com's avatar
      In a pattern binding, a type sig in the pattern cannot bind a type variable · 2f647ec6
      simonpj@microsoft.com authored
      In a pattern binding with a pattern type signature, such as
      
      	(Just (x::a)) = e
      
      the pattern type signature cannot bind type variables.  Hence
      'a' must be in scope already for the above example to be legal.
      
      This has been the situation for some time, but Dan changed it when
      adding view patterns.  This one-line change restores the old behaviour.
      2f647ec6
  31. 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