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. 03 Dec, 2014 1 commit
  4. 28 Nov, 2014 2 commits
    • thomasw's avatar
      Implement Partial Type Signatures · d831b6f4
      thomasw authored
      Summary:
      Add support for Partial Type Signatures, i.e. holes in types, see:
      https://ghc.haskell.org/trac/ghc/wiki/PartialTypeSignatures
      
      This requires an update to the Haddock submodule.
      
      Test Plan: validate
      
      Reviewers: austin, goldfire, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie, Iceland_jack, dominique.devriese, simonmar, carter, goldfire
      
      Differential Revision: https://phabricator.haskell.org/D168
      
      GHC Trac Issues: #9478
      d831b6f4
    • Simon Peyton Jones's avatar
      Kind variables in RHS of an associated type instances should be bound on LHS · 171101be
      Simon Peyton Jones authored
      This patche fixes Trac #9574.
      
      The previous Note [Renaming associated types] in RnTypes appears to me to be wrong;
      it confused class and instance declarations.
      
      I have:
      
       * Treated kind and type variables uniformly. Both must be bound on the LHS
         of an associated type instance.  Eg
             instance C ('KProxy :: KProxy o) where
                type F 'KProxy = NatTr (Proxy :: o -> *)
         is illegal because 'o' is not bound on the LHS of the instance.
      
       * Moved the Note to RnSource and fixed it up
      
      This improves the error message from T7938. However it made the code in
      T6118 incorrect. We had:
        instance SingE (a :: Maybe k) where
          type Demote a = Maybe (Demote (Any :: k))
      and that is now rejected, rightly I think.
      171101be
  5. 21 Nov, 2014 1 commit
  6. 26 Sep, 2014 1 commit
  7. 18 Sep, 2014 1 commit
  8. 06 Sep, 2014 1 commit
  9. 12 Jun, 2014 1 commit
  10. 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
  11. 25 Nov, 2013 1 commit
    • Simon Peyton Jones's avatar
      Another raft of Template Haskell clean-up · 51deeb0d
      Simon Peyton Jones authored
      The handling of typed and untyped brackets was extremely convoluted,
      partly because of the evolutionary history.  I've tidied it all up.
      
      See Note [How brackets and nested splices are handled] in TcSplice
      for the full story
      
      Main changes:
      
       * Untyped brackets: after the renamer, HsRnBracketOut carries
         PendingRnSplices for splices in untyped brackets.  In the
         typechecker, these pending splices are typechecked quite
         straigtforwardly, with no ps_var nonsense.
      
       * Typed brackets: after the renamer typed brackest still look
         like HsBracket. The type checker does the ps_var thing.
      
       * In TcRnTypes.ThStage, the Brack constructor, we distinguish
         the renaming from typehecking pending-stuff.  Much more
         perspicuous!
      
       * The "typed" flag is in HsSpliceE, not in HsSplice, because
         only expressions can be typed.  Patterns, types, declarations
         cannot.
      
      There is further improvement to be done to make the handling of
      declaration splices more uniform.
      51deeb0d
  12. 06 Nov, 2013 1 commit
  13. 12 Oct, 2013 1 commit
  14. 04 Oct, 2013 3 commits
  15. 18 Sep, 2013 1 commit
    • 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
  16. 14 Sep, 2013 1 commit
  17. 03 Sep, 2013 1 commit
  18. 02 Aug, 2013 1 commit
  19. 19 Jun, 2013 1 commit
  20. 03 Jun, 2013 1 commit
  21. 28 May, 2013 1 commit
  22. 03 May, 2013 1 commit
    • Simon Peyton Jones's avatar
      Fix kind quantification (again) · 7a7530a9
      Simon Peyton Jones authored
      We simply weren't quantifying kind variables at the points we
      were claiming.  In paritcular, in
           forall (a:k). blah
      we quantify the 'k' around the 'forall a', provided k isn't
      already in scope
      7a7530a9
  23. 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
  24. 25 Jan, 2013 1 commit
  25. 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
  26. 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
  27. 26 Nov, 2012 1 commit
  28. 16 Oct, 2012 1 commit
    • ian@well-typed.com's avatar
      Some alpha renaming · cd33eefd
      ian@well-typed.com authored
      Mostly d -> g (matching DynFlag -> GeneralFlag).
      Also renamed if* to when*, matching the Haskell if/when names
      cd33eefd
  29. 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
  30. 15 Aug, 2012 1 commit
  31. 13 Jun, 2012 1 commit
    • Simon Peyton Jones's avatar
      Simplify the implementation of Implicit Parameters · 5a8ac0f8
      Simon Peyton Jones authored
      This patch re-implements implicit parameters via a class
      with a functional dependency:
      
          class IP (n::Symbol) a | n -> a where
            ip :: a
      
      This definition is in the library module GHC.IP. Notice
      how it use a type-literal, so we can have constraints like
         IP "x" Int
      Now all the functional dependency machinery works right to make
      implicit parameters behave as they should.
      
      Much special-case processing for implicit parameters can be removed
      entirely. One particularly nice thing is not having a dedicated
      "original-name cache" for implicit parameters (the nsNames field of
      NameCache).  But many other cases disappear:
      
        * BasicTypes.IPName
        * IPTyCon constructor in Tycon.TyCon
        * CIPCan constructor  in TcRnTypes.Ct
        * IPPred constructor  in Types.PredTree
      
      Implicit parameters remain special in a few ways:
      
       * Special syntax.  Eg the constraint (IP "x" Int) is parsed
         and printed as (?x::Int).  And we still have local bindings
         for implicit parameters, and occurrences thereof.
      
       * A implicit-parameter binding  (let ?x = True in e) amounts
         to a local instance declaration, which we have not had before.
         It just generates an implication contraint (easy), but when
         going under it we must purge any existing bindings for
         ?x in the inert set.  See Note [Shadowing of Implicit Parameters]
         in TcSimplify
      
       * TcMType.sizePred classifies implicit parameter constraints as size-0,
         as before the change
      
      There are accompanying patches to libraries 'base' and 'haddock'
      
      All the work was done by Iavor Diatchki
      5a8ac0f8
  32. 05 Jun, 2012 1 commit
  33. 11 May, 2012 1 commit
    • Simon Peyton Jones's avatar
      Refactor LHsTyVarBndrs to fix Trac #6081 · fc8959ac
      Simon Peyton Jones authored
      This is really a small change, but it touches a lot of files quite
      significantly. The real goal is to put the implicitly-bound kind
      variables of a data/class decl in the right place, namely on the
      LHsTyVarBndrs type, which now looks like
      
        data LHsTyVarBndrs name
          = HsQTvs { hsq_kvs :: [Name]
                   , hsq_tvs :: [LHsTyVarBndr name]
            }
      
      This little change made the type checker neater in a number of
      ways, but it was fiddly to push through the changes.
      fc8959ac
  34. 04 May, 2012 1 commit
  35. 13 Apr, 2012 1 commit
    • Simon Peyton Jones's avatar
      Allow kind-variable binders in type signatures · c5554f82
      Simon Peyton Jones authored
      This is the last major addition to the kind-polymorphism story,
      by allowing (Trac #5938)
      
       type family F a   -- F :: forall k. k -> *
       data T a          -- T :: forall k. k -> *
       type instance F (T (a :: Maybe k)) = Char
      
      The new thing is the explicit 'k' in the type signature on 'a',
      which itself is inside a type pattern for F.
      
      Main changes are:
      
      * HsTypes.HsBSig now has a *pair* (kvs, tvs) of binders,
        the kind variables and the type variables
      
      * extractHsTyRdrTyVars returns a pair (kvs, tvs)
        and the function itself has moved from RdrHsSyn to RnTypes
      
      * Quite a bit of fiddling with
           TcHsType.tcHsPatSigType and tcPatSig
        which have become a bit simpler.  I'm still not satisfied
        though.  There's some consequential fiddling in TcRules too.
      
      * Removed the unused HsUtils.collectSigTysFromPats
      
      There's a consequential wibble to Haddock too
      c5554f82
  36. 28 Mar, 2012 1 commit
  37. 26 Mar, 2012 1 commit