1. 05 Oct, 2013 1 commit
  2. 04 Oct, 2013 4 commits
  3. 01 Oct, 2013 2 commits
    • Simon Marlow's avatar
      Add layout to MultiWayIf (#7783) · aab65608
      Simon Marlow authored
      This makes it possible to write
      
      x = if | False -> if | False -> 1
                           | False -> 2
             | True -> 3
      
      Layout normally inserts semicolons between declarations at the same
      indentation level, so I added optional semicolons to the syntax for
      guards in MultiWayIf syntax.  This is a bit of a hack, but the
      alternative (a special kind of layout that doesn't insert semicolons)
      seemed worse, or at least equally bad.
      aab65608
    • Simon Marlow's avatar
  4. 18 Sep, 2013 2 commits
    • twanvl's avatar
      Implement checkable "minimal complete definitions" (#7633) · bd42c9df
      twanvl authored
      
      
      This commit adds a `{-# MINIMAL #-}` pragma, which defines the possible
      minimal complete definitions for a class. The body of the pragma is a
      boolean formula of names.
      
      The old warning for missing methods is replaced with this new one.
      
      Note: The interface file format is changed to store the minimal complete
      definition.
      Authored-by: twanvl's avatarTwan van Laarhoven <twanvl@gmail.com>
      Signed-off-by: Herbert Valerio Riedel's avatarHerbert Valerio Riedel <hvr@gnu.org>
      bd42c9df
    • eir@cis.upenn.edu's avatar
      Change role annotation syntax. · f4046b50
      eir@cis.upenn.edu authored
      This fixes bugs #8185, #8234, and #8246. The new syntax is explained
      in the comments to #8185, appears in the "Roles" subsection of the
      manual, and on the [wiki:Roles] wiki page.
      
      This change also removes the ability for a role annotation on type
      synonyms, as noted in #8234.
      f4046b50
  5. 14 Sep, 2013 1 commit
  6. 09 Sep, 2013 1 commit
    • thoughtpolice's avatar
      Fix optimization of Parser.y.pp · 9f8e9d29
      thoughtpolice authored
      
      
      In 9e133b, the build was modified to pass -fcmm-sink to Parser, but
      unfortunately Parser specifies -O0 in its OPTIONS_GHC directive, meaning
      the sinking pass was actually turned off.
      
      HC_OPTS is the last thing passed to the compiler for that source file
      however, so the correct fix is to also move -O0 out into the build
      system as well.
      
      This was uncovered thanks to a build report from Kazu Yamamoto. Thanks
      to Jan Stolarek for eyeballing this bug and finding it.
      Signed-off-by: thoughtpolice's avatarAustin Seipp <aseipp@pobox.com>
      9f8e9d29
  7. 06 Sep, 2013 1 commit
    • thoughtpolice's avatar
      Add basic support for GHCJS · b372e8ea
      thoughtpolice authored
      
      
      This patch encompasses most of the basic infrastructure for GHCJS. It
      includes:
      
        * A new extension, -XJavaScriptFFI
        * A new architecture, ArchJavaScript
        * Parser and lexer support for 'foreign import javascript', only
          available under -XJavaScriptFFI, using ArchJavaScript.
        * As a knock-on, there is also a new 'WayCustom' constructor in
          DynFlags, so clients of the GHC API can add custom 'tags' to their
          built files. This should be useful for other users as well.
      
      The remaining changes are really just the resulting fallout, making sure
      all the cases are handled appropriately for DynFlags and Platform.
      Authored-by: Luite Stegeman's avatarLuite Stegeman <stegeman@gmail.com>
      Signed-off-by: thoughtpolice's avatarAustin Seipp <aseipp@pobox.com>
      b372e8ea
  8. 04 Sep, 2013 1 commit
    • thoughtpolice's avatar
      Make sure -fcmm-sink is passed to Parser properly · 9e133b9d
      thoughtpolice authored
      
      
      Parser.hs needs to be compiled with -fcmm-sink on x86 platforms, so the
      register allocator doesn't run out of stack slots. Previously, we had to
      do some CPP hacks in order to emit an #ifdef into the file - this is
      because we preprocess it once up front, and run the preprocessor again
      when we compile it.
      
      There's two cases: the boostrap compiler is > 7.8, and the stage1 parser
      needs the flag, or the stage1 compiler is compiling the stage2
      Parser.hs, and needs the flag..
      
      The previous approach was super fragile with Clang. The more principled
      fix is to instead do this through the build system.
      
      This fixes #8182.
      Signed-off-by: thoughtpolice's avatarAustin Seipp <aseipp@pobox.com>
      9e133b9d
  9. 24 Aug, 2013 1 commit
  10. 19 Aug, 2013 3 commits
  11. 05 Aug, 2013 1 commit
  12. 02 Aug, 2013 1 commit
  13. 27 Jul, 2013 1 commit
  14. 21 Jun, 2013 1 commit
    • eir@cis.upenn.edu's avatar
      Revise implementation of overlapping type family instances. · 569b2652
      eir@cis.upenn.edu authored
      This commit changes the syntax and story around overlapping type
      family instances. Before, we had "unbranched" instances and
      "branched" instances. Now, we have closed type families and
      open ones.
      
      The behavior of open families is completely unchanged. In particular,
      coincident overlap of open type family instances still works, despite
      emails to the contrary.
      
      A closed type family is declared like this:
      > type family F a where
      >   F Int = Bool
      >   F a   = Char
      The equations are tried in order, from top to bottom, subject to
      certain constraints, as described in the user manual. It is not
      allowed to declare an instance of a closed family.
      569b2652
  15. 17 Jun, 2013 1 commit
  16. 19 May, 2013 1 commit
  17. 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
  18. 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
  19. 12 Feb, 2013 1 commit
  20. 01 Feb, 2013 2 commits
  21. 14 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Be willing to parse {-# UNPACK #-} without '!' · deec5b74
      Simon Peyton Jones authored
      This change gives a more helpful error message when the
      user says    data T = MkT {-# UNPACK #-} Int
      which should have a strictness '!' as well. Rather than
      just a parse error, we get
      
        T7562.hs:3:14: Warning:
          UNPACK pragma lacks '!' on the first argument of `MkT'
      
      Fixes Trac #7562
      deec5b74
  22. 04 Jan, 2013 1 commit
    • Simon Peyton Jones's avatar
      Allow empty case expressions (and lambda-case) with -XEmptyCase · 3671e674
      Simon Peyton Jones authored
      The main changes are:
        * Parser accepts empty case alternatives
        * Renamer checks that -XEmptyCase is on in that case
        * (Typechecker is pretty much unchanged.)
        * Desugarer desugars empty case alternatives, esp:
            - Match.matchWrapper and Match.match now accept empty eqns
            - New function matchEmpty deals with the empty case
            - See Note [Empty case alternatives] in Match
      
      This patch contains most of the work, but it's a bit mixed up
      with a refactoring of MatchGroup that I did at the same time
      (next commit).
      3671e674
  23. 22 Dec, 2012 1 commit
    • eir@cis.upenn.edu's avatar
      Implement overlapping type family instances. · 8366792e
      eir@cis.upenn.edu authored
      An ordered, overlapping type family instance is introduced by 'type
      instance
      where', followed by equations. See the new section in the user manual
      (7.7.2.2) for details. The canonical example is Boolean equality at the
      type
      level:
      
      type family Equals (a :: k) (b :: k) :: Bool
      type instance where
        Equals a a = True
        Equals a b = False
      
      A branched family instance, such as this one, checks its equations in
      order
      and applies only the first the matches. As explained in the note
      [Instance
      checking within groups] in FamInstEnv.lhs, we must be careful not to
      simplify,
      say, (Equals Int b) to False, because b might later unify with Int.
      
      This commit includes all of the commits on the overlapping-tyfams
      branch. SPJ
      requested that I combine all my commits over the past several months
      into one
      monolithic commit. The following GHC repos are affected: ghc, testsuite,
      utils/haddock, libraries/template-haskell, and libraries/dph.
      
      Here are some details for the interested:
      
      - The definition of CoAxiom has been moved from TyCon.lhs to a
        new file CoAxiom.lhs. I made this decision because of the
        number of definitions necessary to support BranchList.
      
      - BranchList is a GADT whose type tracks whether it is a
        singleton list or not-necessarily-a-singleton-list. The reason
        I introduced this type is to increase static checking of places
        where GHC code assumes that a FamInst or CoAxiom is indeed a
        singleton. This assumption takes place roughly 10 times
        throughout the code. I was worried that a future change to GHC
        would invalidate the assumption, and GHC might subtly fail to
        do the right thing. By explicitly labeling CoAxioms and
        FamInsts as being Unbranched (singleton) or
        Branched (not-necessarily-singleton), we make this assumption
        explicit and checkable. Furthermore, to enforce the accuracy of
        this label, the list of branches of a CoAxiom or FamInst is
        stored using a BranchList, whose constructors constrain its
        type index appropriately.
      
      I think that the decision to use BranchList is probably the most
      controversial decision I made from a code design point of view.
      Although I provide conversions to/from ordinary lists, it is more
      efficient to use the brList... functions provided in CoAxiom than
      always to convert. The use of these functions does not wander far
      from the core CoAxiom/FamInst logic.
      
      BranchLists are motivated and explained in the note [Branched axioms] in
      CoAxiom.lhs.
      
      - The CoAxiom type has changed significantly. You can see the new
        type in CoAxiom.lhs. It uses a CoAxBranch type to track
        branches of the CoAxiom. Correspondingly various functions
        producing and consuming CoAxioms had to change, including the
        binary layout of interface files.
      
      - To get branched axioms to work correctly, it is important to have a
        notion
        of type "apartness": two types are apart if they cannot unify, and no
        substitution of variables can ever get them to unify, even after type
      family
        simplification. (This is different than the normal failure to unify
      because
        of the type family bit.) This notion in encoded in tcApartTys, in
      Unify.lhs.
        Because apartness is finer-grained than unification, the tcUnifyTys
      now
        calls tcApartTys.
      
      - CoreLinting axioms has been updated, both to reflect the new
        form of CoAxiom and to enforce the apartness rules of branch
        application. The formalization of the new rules is in
        docs/core-spec/core-spec.pdf.
      
      - The FamInst type (in types/FamInstEnv.lhs) has changed
        significantly, paralleling the changes to CoAxiom. Of course,
        this forced minor changes in many files.
      
      - There are several new Notes in FamInstEnv.lhs, including one
        discussing confluent overlap and why we're not doing it.
      
      - lookupFamInstEnv, lookupFamInstEnvConflicts, and
        lookup_fam_inst_env' (the function that actually does the work)
        have all been more-or-less completely rewritten. There is a
        Note [lookup_fam_inst_env' implementation] describing the
        implementation. One of the changes that affects other files is
        to change the type of matches from a pair of (FamInst, [Type])
        to a new datatype (which now includes the index of the matching
        branch). This seemed a better design.
      
      - The TySynInstD constructor in Template Haskell was updated to
        use the new datatype TySynEqn. I also bumped the TH version
        number, requiring changes to DPH cabal files. (That's why the
        DPH repo has an overlapping-tyfams branch.)
      
      - As SPJ requested, I refactored some of the code in HsDecls:
      
       * splitting up TyDecl into SynDecl and DataDecl, correspondingly
         changing HsTyDefn to HsDataDefn (with only one constructor)
      
       * splitting FamInstD into TyFamInstD and DataFamInstD and
         splitting FamInstDecl into DataFamInstDecl and TyFamInstDecl
      
       * making the ClsInstD take a ClsInstDecl, for parallelism with
         InstDecl's other constructors
      
       * changing constructor TyFamily into FamDecl
      
       * creating a FamilyDecl type that stores the details for a family
         declaration; this is useful because FamilyDecls can appear in classes
      but
         other decls cannot
      
       * restricting the associated types and associated type defaults for a
       * class
         to be the new, more restrictive types
      
       * splitting cid_fam_insts into cid_tyfam_insts and cid_datafam_insts,
         according to the new types
      
       * perhaps one or two more that I'm overlooking
      
      None of these changes has far-reaching implications.
      
      - The user manual, section 7.7.2.2, is updated to describe the new type
        family
        instances.
      8366792e
  24. 21 Dec, 2012 1 commit
  25. 19 Dec, 2012 1 commit
  26. 14 Dec, 2012 1 commit
    • Simon Peyton Jones's avatar
      Major refactoring of the way that UNPACK pragmas are handled · faa8ff40
      Simon Peyton Jones authored
      The situation was pretty dire.  The way in which data constructors
      were handled, notably the mapping between their *source* argument types
      and their *representation* argument types (after seq'ing and unpacking)
      was scattered in three different places, and hard to keep in sync.
      
      Now it is all in one place:
      
       * The dcRep field of a DataCon gives its representation,
         specified by a DataConRep
      
       * As well as having the wrapper, the DataConRep has a "boxer"
         of type DataConBoxer (defined in MkId for loopy reasons).
         The boxer used at a pattern match to reconstruct the source-level
         arguments from the rep-level bindings in the pattern match.
      
       * The unboxing in the wrapper and the boxing in the boxer are dual,
         and are now constructed together, by MkId.mkDataConRep. This is
         the key function of this change.
      
       * All the computeBoxingStrategy code in TcTyClsDcls disappears.
      
      Much nicer.
      
      There is a little bit of refactoring left to do; the strange
      deepSplitProductType functions are now called only in WwLib, so
      I moved them there, and I think they could be tidied up further.
      faa8ff40
  27. 05 Dec, 2012 1 commit
  28. 30 Nov, 2012 2 commits
  29. 10 Nov, 2012 1 commit
  30. 23 Oct, 2012 1 commit
  31. 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