1. 10 Feb, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor the handling of quasi-quotes · f46360ed
      Simon Peyton Jones authored
      As Trac #10047 points out, a quasi-quotation [n|...blah...|] is supposed
      to behave exactly like $(n "...blah...").  But it doesn't!  This was outright
      wrong: quasiquotes were being run even inside brackets.
      
      Now that TH supports both typed and untyped splices, a quasi-quote is properly
      regarded as a particular syntax for an untyped splice. But apart from that
      they should be treated the same.  So this patch refactors the handling of
      quasiquotes to do just that.
      
      The changes touch quite a lot of files, but mostly in a routine way.
      The biggest changes by far are in RnSplice, and more minor changes in
      TcSplice.  These are the places where there was real work to be done.
      Everything else is routine knock-on changes.
      
      * No more QuasiQuote forms in declarations, expressions, types, etc.
        So we get rid of these data constructors
          * HsBinds.QuasiQuoteD
          * HsExpr.HsSpliceE
          * HsPat.QuasiQuotePat
          * HsType.HsQuasiQuoteTy
      
      * We get rid of the HsQuasiQuote type altogether
      
      * Instead, we augment the HsExpr.HsSplice type to have three
        consructors, for the three types of splice:
          * HsTypedSplice
          * HsUntypedSplice
          * HsQuasiQuote
        There are some related changes in the data types in HsExpr near HsSplice.
        Specifically: PendingRnSplice, PendingTcSplice, UntypedSpliceFlavour.
      
      * In Hooks, we combine rnQuasiQuoteHook and rnRnSpliceHook into one.
        A smaller, clearer interface.
      
      * We have to update the Haddock submodule, to accommodate the hsSyn changes
      f46360ed
  2. 16 Jan, 2015 1 commit
    • Alan Zimmerman's avatar
      API Annotations tweaks. · 11881ec6
      Alan Zimmerman authored
      Summary:
      HsTyLit now has SourceText
      
      Update documentation of HsSyn to reflect which annotations are attached to which element.
      
      Ensure that the parser always keeps HsSCC and HsTickPragma values, to
      be ignored in the desugar phase if not needed
      
      Bringing in SourceText for pragmas
      
      Add Location in NPlusKPat
      
      Add Location in FunDep
      
      Make RecCon payload Located
      
      Explicitly add AnnVal to RdrName where it is compound
      
      Add Location in IPBind
      
      Add Location to name in IEThingAbs
      
      Add Maybe (Located id,Bool) to Match to track fun_id,infix
        This includes converting Match into a record and adding a note about why
        the fun_id needs to be replicated in the Match.
      
      Add Location in KindedTyVar
      
      Sort out semi-colons for parsing
      
        - import statements
        - stmts
        - decls
        - decls_cls
        - decls_inst
      
      This updates the haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin, goldfire, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D538
      11881ec6
  3. 06 Jan, 2015 1 commit
    • 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
  4. 03 Dec, 2014 1 commit
  5. 26 Sep, 2014 1 commit
  6. 07 Aug, 2014 1 commit
  7. 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
  8. 13 Apr, 2014 1 commit
  9. 27 Nov, 2013 1 commit
    • Joachim Breitner's avatar
      Roleify TcCoercion · 9d643cf6
      Joachim Breitner authored
      Previously, TcCoercion were only used to represent boxed Nominal
      coercions. In order to also talk about boxed Representational coercions
      in the type checker, we add Roles to TcCoercion. Again, we closely
      mirror Coercion.
      
      The roles are verified by a few assertions, and at the latest after
      conversion to Coercion. I have put my trust in the comprehensiveness of
      the testsuite here, but any role error after desugaring popping up now
      might be caused by this refactoring.
      9d643cf6
  10. 04 Oct, 2013 1 commit
  11. 01 Oct, 2013 1 commit
  12. 04 Mar, 2013 1 commit
    • Simon Peyton Jones's avatar
      Rearrange the typechecking of arrows, especially arrow "forms" · c3ad38d7
      Simon Peyton Jones authored
      The typechecking of arrow forms (in GHC 7.6) is known to be bogus, as
      described in Trac #5609, because it marches down tuple types that may
      not yet be fully worked out, depending on when constraint solving
      happens.  Moreover, coercions are generated and simply discarded.  The
      fact that it works at all is a miracle.
      
      This refactoring is based on a conversation with Ross, where we
      rearranged the typing of the argument stack, so that the arrows
      have the form
         a (env, (arg1, (arg2, ...(argn, ())))) res
      rather than
         a (arg1, (arg2, ...(argn, env))) res
      as it was before.
      
      This is vastly simpler to typecheck; just look at the beautiful,
      simple type checking of arrow forms now!
      
      We need a new HsCmdCast to capture the coercions generated from
      the argument stack.
      
      This leaves us in a better position to tackle the open arrow tickets
       * Trac #5777 still fails.  (I was hoping this patch would cure it.)
       * Trac #5609 is too complicated for me to grok.  Ross?
       * Trac #344
       * Trac #5333
      c3ad38d7
  13. 14 Feb, 2013 1 commit
    • Simon Peyton Jones's avatar
      Add OverloadedLists, allowing list syntax to be overloaded · 3234a4ad
      Simon Peyton Jones authored
      This work was all done by
         Achim Krause <achim.t.krause@gmail.com>
         George Giorgidze <giorgidze@gmail.com>
         Weijers Jeroen <jeroen.weijers@uni-tuebingen.de>
      
      It allows list syntax, such as [a,b], [a..b] and so on, to be
      overloaded so that it works for a variety of types.
      
      The design is described here:
          http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists
      
      Eg. you can use it for maps, so that
              [(1,"foo"), (4,"bar")] :: Map Int String
      
      The main changes
       * The ExplicitList constructor of HsExpr gets witness field
       * Ditto ArithSeq constructor
       * Ditto the ListPat constructor of HsPat
      
      Everything else flows from this.
      3234a4ad
  14. 04 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Refactor HsExpr.MatchGroup · a8941e2a
      Simon Peyton Jones authored
       * Make MatchGroup into a record, and use the record fields
      
       * Split the type field into two: mg_arg_tys and mg_res_ty
         This makes life much easier for the desugarer when the
         case alterantives are empty
      
      A little bit of this change unavoidably ended up in the preceding
      commit about empty case alternatives
      a8941e2a
  15. 23 Dec, 2012 1 commit
  16. 03 Oct, 2012 1 commit
    • Simon Peyton Jones's avatar
      This big patch re-factors the way in which arrow-syntax is handled · ba56d20d
      Simon Peyton Jones authored
      All the work was done by Dan Winograd-Cort.
      
      The main thing is that arrow comamnds now have their own
      data type HsCmd (defined in HsExpr).  Previously it was
      punned with the HsExpr type, which was jolly confusing,
      and made it hard to do anything arrow-specific.
      
      To make this work, we now parameterise
        * MatchGroup
        * Match
        * GRHSs, GRHS
        * StmtLR and friends
      over the "body", that is the kind of thing they
      enclose.  This "body" parameter can be instantiated to
      either LHsExpr or LHsCmd respectively.
      
      Everything else is really a knock-on effect; there should
      be no change (yet!) in behaviour.  But it should be a sounder
      basis for fixing bugs.
      ba56d20d
  17. 01 May, 2012 1 commit
    • Simon Peyton Jones's avatar
      Tidy up a remaining glitch in unification · 67c793a3
      Simon Peyton Jones authored
      There was one place, in type checking parallel list comprehensions
      where we were unifying types, but had no convenient way to use the
      resulting coercion; instead we just checked that it was Refl.  This
      was Wrong Wrong; it might fail unpredicably in a GADT-like situation,
      and it led to extra error-generation code used only in this one place.
      
      This patch tidies it all up, by moving the 'return' method from the
      *comprehension* to the ParStmtBlock. The latter is a new data type,
      now used for each sub-chunk of a parallel list comprehension.
      
      Because of the data type change, quite a few modules are touched,
      but only in a fairly trivial way. The real changes are in TcMatches
      (and corresponding desugaring); plus deleting code from TcUnify.
      
      This patch also fixes the pretty-printing bug in Trac #6060
      67c793a3
  18. 19 Dec, 2011 1 commit
    • Ross Paterson's avatar
      fix #5022: polymorphic definitions inside arrow rec · 4c8e0307
      Ross Paterson authored
      This is quite tricky, with examples like this:
      
      import Control.Arrow
      
      pRepeat :: a -> [a]
      pRepeat =
          proc x -> do
            rec
              s <- returnA -< f_rec x:s       -- f_rec is monomorphic here
              let f_later y = y               -- f_later is polymorphic here
              _ <- returnA -< (f_later True, f_later 'a')
              let f_rec y = y                 -- f_rec is polymorphic here
            returnA -< f_later s              -- f_later is monomorphic here
      
      Fixed the typechecking of arrow RecStmt to track changes to the monad
      version.  It was simplest to add a field recS_later_rets corresponding
      to recS_rec_rets.  It's only used for the arrow version, and always
      empty for the monad version.  But I think it would be cleaner to put
      the rec_ids and later_ids in a single list with supplementary info
      saying how they're used.
      
      Also fixed several glitches in the desugaring of arrow RecStmt.  The fact
      that the monomorphic variables shadow their polymorphic counterparts is a
      major pain.  Also a bit of general cleanup of DsArrows while I was there.
      4c8e0307
  19. 05 Dec, 2011 1 commit
    • Simon Peyton Jones's avatar
      Allow full constraint solving under a for-all (Trac #5595) · 2e6dcdf7
      Simon Peyton Jones authored
      The main idea is that when we unify
          forall a. t1  ~  forall a. t2
      we get constraints from unifying t1~t2 that mention a.
      We are producing a coercion witnessing the equivalence of
      the for-alls, and inside *that* coercion we need bindings
      for the solved constraints arising from t1~t2.
      
      We didn't have way to do this before.  The big change is
      that here's a new type TcEvidence.TcCoercion, which is
      much like Coercion.Coercion except that there's a slot
      for TcEvBinds in it.
      
      This has a wave of follow-on changes. Not deep but broad.
      
      * New module TcEvidence, which now contains the HsWrapper
        TcEvBinds, EvTerm etc types that used to be in HsBinds
      
      * The typechecker works exclusively in terms of TcCoercion.
      
      * The desugarer converts TcCoercion to Coercion
      
      * The main payload is in TcUnify.unifySigmaTy. This is the
        function that had a gross hack before, but is now beautiful.
      
      * LCoercion is gone!  Hooray.
      
      Many many fiddly changes in conssequence.  But it's nice.
      2e6dcdf7
  20. 04 Nov, 2011 1 commit
  21. 02 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Overhaul of infrastructure for profiling, coverage (HPC) and breakpoints · 7bb0447d
      Simon Marlow authored
      User visible changes
      ====================
      
      Profilng
      --------
      
      Flags renamed (the old ones are still accepted for now):
      
        OLD            NEW
        ---------      ------------
        -auto-all      -fprof-auto
        -auto          -fprof-exported
        -caf-all       -fprof-cafs
      
      New flags:
      
        -fprof-auto              Annotates all bindings (not just top-level
                                 ones) with SCCs
      
        -fprof-top               Annotates just top-level bindings with SCCs
      
        -fprof-exported          Annotates just exported bindings with SCCs
      
        -fprof-no-count-entries  Do not maintain entry counts when profiling
                                 (can make profiled code go faster; useful with
                                 heap profiling where entry counts are not used)
      
      Cost-centre stacks have a new semantics, which should in most cases
      result in more useful and intuitive profiles.  If you find this not to
      be the case, please let me know.  This is the area where I have been
      experimenting most, and the current solution is probably not the
      final version, however it does address all the outstanding bugs and
      seems to be better than GHC 7.2.
      
      Stack traces
      ------------
      
      +RTS -xc now gives more information.  If the exception originates from
      a CAF (as is common, because GHC tends to lift exceptions out to the
      top-level), then the RTS walks up the stack and reports the stack in
      the enclosing update frame(s).
      
      Result: +RTS -xc is much more useful now - but you still have to
      compile for profiling to get it.  I've played around a little with
      adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem
      quite accurately.
      
      I plan to add more facilities for stack tracing (e.g. in GHCi) in the
      future.
      
      Coverage (HPC)
      --------------
      
       * derived instances are now coloured yellow if they weren't used
       * likewise record field names
       * entry counts are more accurate (hpc --fun-entry-count)
       * tab width is now correct (markup was previously off in source with
         tabs)
      
      Internal changes
      ================
      
      In Core, the Note constructor has been replaced by
      
              Tick (Tickish b) (Expr b)
      
      which is used to represent all the kinds of source annotation we
      support: profiling SCCs, HPC ticks, and GHCi breakpoints.
      
      Depending on the properties of the Tickish, different transformations
      apply to Tick.  See CoreUtils.mkTick for details.
      
      Tickets
      =======
      
      This commit closes the following tickets, test cases to follow:
      
        - Close #2552: not a bug, but the behaviour is now more intuitive
          (test is T2552)
      
        - Close #680 (test is T680)
      
        - Close #1531 (test is result001)
      
        - Close #949 (test is T949)
      
        - Close #2466: test case has bitrotted (doesn't compile against current
          version of vector-space package)
      7bb0447d
  22. 06 Sep, 2011 1 commit
    • batterseapower's avatar
      Implement -XConstraintKind · 9729fe7c
      batterseapower authored
      Basically as documented in http://hackage.haskell.org/trac/ghc/wiki/KindFact,
      this patch adds a new kind Constraint such that:
      
        Show :: * -> Constraint
        (?x::Int) :: Constraint
        (Int ~ a) :: Constraint
      
      And you can write *any* type with kind Constraint to the left of (=>):
      even if that type is a type synonym, type variable, indexed type or so on.
      
      The following (somewhat related) changes are also made:
       1. We now box equality evidence. This is required because we want
          to give (Int ~ a) the *lifted* kind Constraint
       2. For similar reasons, implicit parameters can now only be of
          a lifted kind. (?x::Int#) => ty is now ruled out
       3. Implicit parameter constraints are now allowed in superclasses
          and instance contexts (this just falls out as OK with the new
          constraint solver)
      
      Internally the following major changes were made:
       1. There is now no PredTy in the Type data type. Instead
          GHC checks the kind of a type to figure out if it is a predicate
       2. There is now no AClass TyThing: we represent classes as TyThings
          just as a ATyCon (classes had TyCons anyway)
       3. What used to be (~) is now pretty-printed as (~#). The box
          constructor EqBox :: (a ~# b) -> (a ~ b)
       4. The type LCoercion is used internally in the constraint solver
          and type checker to represent coercions with free variables
          of type (a ~ b) rather than (a ~# b)
      9729fe7c
  23. 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
  24. 29 Apr, 2011 1 commit
  25. 28 Apr, 2011 1 commit
  26. 22 Dec, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Tidy up rebindable syntax for MDo · ba05282d
      simonpj@microsoft.com authored
      For a long time an 'mdo' expression has had a SyntaxTable
      attached to it.  However, we're busy deprecating SyntaxTables
      in favour of rebindable syntax attached to individual Stmts,
      and MDoExpr was totally inconsistent with DoExpr in this
      regard.
      
      This patch tidies it all up.  Now there's no SyntaxTable on
      MDoExpr, and 'modo' is generally handled much more like 'do'.
      
      There is resulting small change in behaviour: now MonadFix is
      required only if you actually *use* recursion in mdo. This
      seems consistent with the implicit dependency analysis that
      is done for mdo.
      
      Still to do:
        * Deal with #4148 (this patch is on the way)
        * Get rid of the last remaining SyntaxTable on HsCmdTop
      ba05282d
  27. 05 Nov, 2010 1 commit
  28. 22 Oct, 2010 1 commit
    • simonpj@microsoft.com's avatar
      Add rebindable syntax for if-then-else · 4e0c994e
      simonpj@microsoft.com authored
      There are two main changes
      
       * New LANGUAGE option RebindableSyntax, which implies NoImplicitPrelude
      
       * if-the-else becomes rebindable, with function name "ifThenElse"
         (but case expressions are unaffected)
      
      Thanks to Sam Anklesaria for doing most of the work here
      4e0c994e
  29. 14 Sep, 2010 1 commit
  30. 13 Sep, 2010 1 commit
  31. 22 Aug, 2010 1 commit
  32. 15 Jun, 2010 1 commit
  33. 09 Apr, 2010 1 commit
  34. 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
  35. 30 Oct, 2009 1 commit
  36. 28 Oct, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add 'rec' to stmts in a 'do', and deprecate 'mdo' · f04dead9
      simonpj@microsoft.com authored
      The change is this (see Trac #2798).  Instead of writing
      
        mdo { a <- getChar
            ; b <- f c
            ; c <- g b
            ; putChar c
            ; return b }
      
      you would write
      
        do { a <- getChar
           ; rec { b <- f c
                 ; c <- g b }
           ; putChar c
           ; return b }
      
      That is, 
        * 'mdo' is eliminated 
        * 'rec' is added, which groups a bunch of statements
          into a single recursive statement
      
      This 'rec' thing is already present for the arrow notation, so it  
      makes the two more uniform.  Moreover, 'rec' lets you say more
      precisely where the recursion is (if you want to), whereas 'mdo' just
      says "there's recursion here somewhere".  Lastly, all this works with
      rebindable syntax (which mdo does not).
      
      Currently 'mdo' is enabled by -XRecursiveDo.  So we now deprecate this
      flag, with another flag -XDoRec to enable the 'rec' keyword.
      
      Implementation notes:
        * Some changes in Lexer.x
        * All uses of RecStmt now use record syntax
      
      I'm still not really happy with the "rec_ids" and "later_ids" in the
      RecStmt constructor, but I don't dare change it without consulting Ross
      about the consequences for arrow syntax.
      f04dead9
  37. 23 Jul, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Add tuple sections as a new feature · 58521c72
      simonpj@microsoft.com authored
      This patch adds tuple sections, so that
      
      	(x,,z)  means   \y -> (x,y,z)
      
      Thanks for Max Bolinbroke for doing the hard work.
      
      In the end, instead of using two constructors in HsSyn, I used
      just one (still called ExplicitTuple) whose arguments can be
      	Present (LHsExpr id)
      or	Missing PostTcType
      
      While I was at it, I did a bit of refactoring too.
      58521c72
  38. 31 Jul, 2008 2 commits
  39. 04 May, 2008 1 commit