1. 17 Oct, 2016 1 commit
    • Simon Peyton Jones's avatar
      Correct order of existentials in pattern synonyms · a693d1cb
      Simon Peyton Jones authored
      Trac #12698 exposed a nasty bug in the typechecking for
      pattern synonmys: the existential type variables weren't
      being put in properly-scoped order.
      
      For some reason TcPatSyn.tcCollectEx was colleting them as a
      set, not as a list!  Easily fixed.
      a693d1cb
  2. 11 Sep, 2016 1 commit
  3. 17 Aug, 2016 1 commit
    • Simon Peyton Jones's avatar
      Keep the bindings local during defaultCallStacks · f352e5cd
      Simon Peyton Jones authored
      defaultCallStacks generates evidence bindings for call stacks,
      but wasn't setting the binding site correctly.  As a result
      they were simply discarded in the case of pattern synonyms,
      giving rise to Trac #12489.
      
      The fix is easy; and I added an ASSERT to catch the error earlier.
      f352e5cd
  4. 21 Jul, 2016 1 commit
    • Ömer Sinan Ağacan's avatar
      Implement unboxed sum primitive type · 714bebff
      Ömer Sinan Ağacan authored
      Summary:
      This patch implements primitive unboxed sum types, as described in
      https://ghc.haskell.org/trac/ghc/wiki/UnpackedSumTypes.
      
      Main changes are:
      
      - Add new syntax for unboxed sums types, terms and patterns. Hidden
        behind `-XUnboxedSums`.
      
      - Add unlifted unboxed sum type constructors and data constructors,
        extend type and pattern checkers and desugarer.
      
      - Add new RuntimeRep for unboxed sums.
      
      - Extend unarise pass to translate unboxed sums to unboxed tuples right
        before code generation.
      
      - Add `StgRubbishArg` to `StgArg`, and a new type `CmmArg` for better
        code generation when sum values are involved.
      
      - Add user manual section for unboxed sums.
      
      Some other changes:
      
      - Generalize `UbxTupleRep` to `MultiRep` and `UbxTupAlt` to
        `MultiValAlt` to be able to use those with both sums and tuples.
      
      - Don't use `tyConPrimRep` in `isVoidTy`: `tyConPrimRep` is really
        wrong, given an `Any` `TyCon`, there's no way to tell what its kind
        is, but `kindPrimRep` and in turn `tyConPrimRep` returns `PtrRep`.
      
      - Fix some bugs on the way: #12375.
      
      Not included in this patch:
      
      - Update Haddock for new the new unboxed sum syntax.
      
      - `TemplateHaskell` support is left as future work.
      
      For reviewers:
      
      - Front-end code is mostly trivial and adapted from unboxed tuple code
        for type checking, pattern checking, renaming, desugaring etc.
      
      - Main translation routines are in `RepType` and `UnariseStg`.
        Documentation in `UnariseStg` should be enough for understanding
        what's going on.
      
      Credits:
      
      - Johan Tibell wrote the initial front-end and interface file
        extensions.
      
      - Simon Peyton Jones reviewed this patch many times, wrote some code,
        and helped with debugging.
      
      Reviewers: bgamari, alanz, goldfire, RyanGlScott, simonpj, austin,
                 simonmar, hvr, erikd
      
      Reviewed By: simonpj
      
      Subscribers: Iceland_jack, ggreif, ezyang, RyanGlScott, goldfire,
                   thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2259
      714bebff
  5. 25 Jun, 2016 1 commit
    • eir@cis.upenn.edu's avatar
      s/Invisible/Inferred/g s/Visible/Required/g · 5fdb854c
      eir@cis.upenn.edu authored
      This renames VisibilityFlag from
      
      > data VisibilityFlag = Visible | Specified | Invisible
      
      to
      
      > data ArgFlag = Required | Specified | Inferred
      
      The old name was quite confusing, because both Specified
      and Invisible were invisible! The new names are hopefully clearer.
      5fdb854c
  6. 23 Jun, 2016 1 commit
  7. 15 Jun, 2016 2 commits
    • Simon Peyton Jones's avatar
      Major patch to introduce TyConBinder · e368f326
      Simon Peyton Jones authored
      Before this patch, following the TypeInType innovations,
      each TyCon had two lists:
        - tyConBinders :: [TyBinder]
        - tyConTyVars  :: [TyVar]
      
      They were in 1-1 correspondence and contained
      overlapping information.  More broadly, there were many
      places where we had to pass around this pair of lists,
      instead of a single list.
      
      This commit tidies all that up, by having just one list of
      binders in a TyCon:
      
        - tyConBinders :: [TyConBinder]
      
      The new data types look like this:
      
        Var.hs:
           data TyVarBndr tyvar vis = TvBndr tyvar vis
           data VisibilityFlag = Visible | Specified | Invisible
           type TyVarBinder = TyVarBndr TyVar VisibilityFlag
      
        TyCon.hs:
           type TyConBinder = TyVarBndr TyVar TyConBndrVis
      
           data TyConBndrVis
             = NamedTCB VisibilityFlag
             | AnonTCB
      
        TyCoRep.hs:
           data TyBinder
             = Named TyVarBinder
             | Anon Type
      
      Note that Var.TyVarBdr has moved from TyCoRep and has been
      made polymorphic in the tyvar and visiblity fields:
      
           type TyVarBinder = TyVarBndr TyVar VisibilityFlag
              -- Used in ForAllTy
           type TyConBinder = TyVarBndr TyVar TyConBndrVis
              -- Used in TyCon
      
           type IfaceForAllBndr  = TyVarBndr IfaceTvBndr VisibilityFlag
           type IfaceTyConBinder = TyVarBndr IfaceTvBndr TyConBndrVis
               -- Ditto, in interface files
      
      There are a zillion knock-on changes, but everything
      arises from these types.  It was a bit fiddly to get the
      module loops to work out right!
      
      Some smaller points
      ~~~~~~~~~~~~~~~~~~~
      * Nice new functions
          TysPrim.mkTemplateKiTyVars
          TysPrim.mkTemplateTyConBinders
        which help you make the tyvar binders for dependently-typed
        TyCons.  See comments with their definition.
      
      * The change showed up a bug in TcGenGenerics.tc_mkRepTy, where the code
        was making an assumption about the order of the kind variables in the
        kind of GHC.Generics.(:.:).  I fixed this; see TcGenGenerics.mkComp.
      e368f326
    • Simon Peyton Jones's avatar
      Re-add FunTy (big patch) · 77bb0927
      Simon Peyton Jones authored
      With TypeInType Richard combined ForAllTy and FunTy, but that was often
      awkward, and yielded little benefit becuase in practice the two were
      always treated separately.  This patch re-introduces FunTy.  Specfically
      
      * New type
          data TyVarBinder = TvBndr TyVar VisibilityFlag
        This /always/ has a TyVar it.  In many places that's just what
        what we want, so there are /lots/ of TyBinder -> TyVarBinder changes
      
      * TyBinder still exists:
          data TyBinder = Named TyVarBinder | Anon Type
      
      * data Type = ForAllTy TyVarBinder Type
                  | FunTy Type Type
                  |  ....
      
      There are a LOT of knock-on changes, but they are all routine.
      
      The Haddock submodule needs to be updated too
      77bb0927
  8. 13 Jun, 2016 1 commit
    • Simon Peyton Jones's avatar
      Improve typechecking of let-bindings · 15b9bf4b
      Simon Peyton Jones authored
      This major commit was initially triggered by #11339, but it spiraled
      into a major review of the way in which type signatures for bindings
      are handled, especially partial type signatures.  On the way I fixed a
      number of other bugs, namely
         #12069
         #12033
         #11700
         #11339
         #11670
      
      The main change is that I completely reorganised the way in which type
      signatures in bindings are handled. The new story is in TcSigs
      Note [Overview of type signatures].  Some specific:
      
      * Changes in the data types for signatures in TcRnTypes:
        TcIdSigInfo and new TcIdSigInst
      
      * New module TcSigs deals with typechecking type signatures
        and pragmas. It contains code mostly moved from TcBinds,
        which is already too big
      
      * HsTypes: I swapped the nesting of HsWildCardBndrs
        and HsImplicitBndsrs, so that the wildcards are on the
        oustide not the insidde in a LHsSigWcType.  This is just
        a matter of convenient, nothing deep.
      
      There are a host of other changes as knock-on effects, and
      it all took FAR longer than I anticipated :-).  But it is
      a significant improvement, I think.
      
      Lots of error messages changed slightly, some just variants but
      some modest improvements.
      
      New tests
      
      * typecheck/should_compile
          * SigTyVars: a scoped-tyvar test
          * ExPat, ExPatFail: existential pattern bindings
          * T12069
          * T11700
          * T11339
      
      * partial-sigs/should_compile
          * T12033
          * T11339a
          * T11670
      
      One thing to check:
      
      * Small change to output from ghc-api/landmines.
        Need to check with Alan Zimmerman
      15b9bf4b
  9. 06 Jun, 2016 1 commit
    • Alan Zimmerman's avatar
      Merge MatchFixity and HsMatchContext · a13cb279
      Alan Zimmerman authored
      Summary:
      MatchFixity was introduced to facilitate use of API Annotations.
      
      HsMatchContext does the same thing with more detail, but is chased
      through all over the place to provide context when processing a Match.
      
      Since we already have MatchFixity in the Match, it may as well provide
      the full context.
      
      updates submodule haddock
      
      Test Plan: ./validate
      
      Reviewers: austin, goldfire, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2271
      
      GHC Trac Issues: #12105
      
      (cherry picked from commit 306ecad5)
      a13cb279
  10. 24 May, 2016 1 commit
    • Simon Peyton Jones's avatar
      Don't split the arg types in a PatSyn signature · 03d89603
      Simon Peyton Jones authored
      This patch fixes Trac #11977, and #12108, rather satisfactorily
      maily by deleting code!
      
        pattern P :: Eq a => a -> a -> Int
      
      The idea is simply /not/ to split the bit after the '=>' into the
      pattern argument types, but to keep the (a->a->Int) part
      un-decomposed, in the patsig_body_ty field of a TcPatSynInfo.
      
      There is one awkward wrinkle, which is that we can't split the
      implicitly-bound type variables into existential and universal until
      we know which types are arguments and which are part of the result.
      So we postpone the decision until we have the declaration in hand.
      See TcPatSyn Note [The pattern-synonym signature splitting rule]
      03d89603
  11. 23 May, 2016 2 commits
  12. 16 May, 2016 1 commit
    • niteria's avatar
      Kill varSetElems in tcInferPatSynDecl · 21fe4ffd
      niteria authored
      varSetElems introduces unnecessary non-determinism and while
      I didn't estabilish experimentally that this matters here
      I'm convinced that it will, because I expect pattern synonyms
      to end up in interface files.
      
      Test Plan: ./validate
      
      Reviewers: austin, simonmar, bgamari, mpickering, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2206
      
      GHC Trac Issues: #4012
      21fe4ffd
  13. 28 Apr, 2016 2 commits
    • Simon Peyton Jones's avatar
      Refactor RecordPatSynField, FieldLabel · 3dce4f2d
      Simon Peyton Jones authored
      This patch uses the named fields of
       * FieldLabel
       * RecordPatSynField
      in construction and pattern matching. The fields
      existed before, but we were often using positional notation.
      
      Also a minor refactor of the API of mkPatSynRecSelBinds
      
      No change in functionality
      3dce4f2d
    • Simon Peyton Jones's avatar
      Comments only · 1e86cab4
      Simon Peyton Jones authored
      1e86cab4
  14. 22 Apr, 2016 1 commit
    • Simon Peyton Jones's avatar
      Simplify defaultKindVar and friends · 970ff585
      Simon Peyton Jones authored
      I found zonkQuantifiedTyVar rather complicated, especially the two
      places where we defaulted RuntimeRep variables. This simplifies and
      modularises the story.
      
      Refactoring only.
      970ff585
  15. 20 Apr, 2016 1 commit
  16. 19 Apr, 2016 1 commit
    • Simon Peyton Jones's avatar
      Refactor computing dependent type vars · 17eb2419
      Simon Peyton Jones authored
      There should be no change in behaviour here
      
      * Move splitDepVarsOfType(s) from Type to TcType
      
      * Define data type TcType.TcDepVars, document what it means,
        and use it where appropriate, notably in splitDepVarsOfType(s)
      
      * Use it in TcMType.quantifyTyVars and friends
      17eb2419
  17. 02 Apr, 2016 1 commit
    • Rik Steenkamp's avatar
      Improve printing of pattern synonym types · 72bd7f7b
      Rik Steenkamp authored
      Add the function `pprPatSynType :: PatSyn -> SDoc` for printing pattern
      synonym types, and remove the ambiguous `patSynType` function. Also,
      the types in a `PatSyn` are now tidy.
      
      Haddock submodule updated to reflect the removal of `patSynType` by
      mpickering.
      
      Fixes: #11213.
      
      Reviewers: goldfire, simonpj, austin, mpickering, bgamari
      
      Reviewed By: simonpj, mpickering
      
      Subscribers: bollmann, simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1896
      
      GHC Trac Issues: #11213
      72bd7f7b
  18. 31 Mar, 2016 1 commit
  19. 24 Mar, 2016 1 commit
    • Rik Steenkamp's avatar
      Add `PatSynSigSkol` and modify `PatSynCtxt` · 997312b0
      Rik Steenkamp authored
      As the type of a pattern synonym cannot in general be represented by a
      value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check
      ty)` to represent the signature of a pattern synonym (this causes
      incorrect signatures to be printed in error messages). Therefore we now
      represent it by a value `PatSynSigSkol n` (instead of incorrect
      signatures we simply print no explicit signature).
      
      Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use
      `SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a
      bidirectional pattern synonym when used in an expression context.
      Before, this type was represented by a value `SigSkol (PatSynCtxt n)
      (Check ty)`, which caused incorrect error messages.
      
      Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish
      between all enclosing implications and "useful" enclosing implications,
      for better error messages concerning pattern synonyms. See `Note [Useful
      implications]`.
      
      See the Phabricator page for examples.
      
      Reviewers: mpickering, goldfire, simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1967
      
      GHC Trac Issues: #11667
      997312b0
  20. 21 Mar, 2016 2 commits
    • eir@cis.upenn.edu's avatar
      Zonk before calling splitDepVarsOfType. · 5c0c751a
      eir@cis.upenn.edu authored
      It was Utterly Wrong before.
      
      Note to self: Never, ever take the free vars of an unzonked type.
      5c0c751a
    • eir@cis.upenn.edu's avatar
      Track specified/invisible more carefully. · 35e93797
      eir@cis.upenn.edu authored
      In particular, this allows correct tracking of specified/invisible
      for variables in Haskell98 data constructors and in pattern synonyms.
      GADT-syntax constructors are harder, and are left until #11721.
      
      This was all inspired by Simon's comments to my fix for #11512,
      which this subsumes.
      
      Test case: ghci/scripts/TypeAppData
      
      [skip ci]  (The test case fails because of an unrelated problem
      fixed in the next commit.)
      35e93797
  21. 09 Mar, 2016 1 commit
  22. 26 Feb, 2016 1 commit
  23. 25 Feb, 2016 2 commits
  24. 24 Feb, 2016 1 commit
    • eir@cis.upenn.edu's avatar
      Address #11471 by putting RuntimeRep in kinds. · d8c64e86
      eir@cis.upenn.edu authored
      See Note [TYPE] in TysPrim. There are still some outstanding
      pieces in #11471 though, so this doesn't actually nail the bug.
      
      This commit also contains a few performance improvements:
      
      * Short-cut equality checking of nullary type syns
      
      * Compare types before kinds in eqType
      
      * INLINE coreViewOneStarKind
      
      * Store tycon binders separately from kinds.
      
      This resulted in a ~10% performance improvement in compiling
      the Cabal package. No change in functionality other than
      performance. (This affects the interface file format, though.)
      
      This commit updates the haddock submodule.
      d8c64e86
  25. 16 Feb, 2016 1 commit
  26. 09 Feb, 2016 1 commit
  27. 02 Feb, 2016 1 commit
    • niteria's avatar
      Use a correct substitution in tcCheckPatSynDecl · 07ed2413
      niteria authored
      The `substTheta` call didn't have the free variables of the
      `prov_theta` in the `in_scope` set. It should be enough to add
      `univ_tvs`, as all the `ex_tvs` are already in the domain of
      the substitution.
      
      Test Plan: added a testcase
      
      Reviewers: simonpj, bgamari, goldfire, austin
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1879
      
      GHC Trac Issues: #11524
      07ed2413
  28. 27 Jan, 2016 2 commits
    • eir@cis.upenn.edu's avatar
      Refactor the typechecker to use ExpTypes. · 00cbbab3
      eir@cis.upenn.edu authored
      The idea here is described in [wiki:Typechecker]. Briefly,
      this refactor keeps solid track of "synthesis" mode vs
      "checking" in GHC's bidirectional type-checking algorithm.
      When in synthesis mode, the expected type is just an IORef
      to write to.
      
      In addition, this patch does a significant reworking of
      RebindableSyntax, allowing much more freedom in the types
      of the rebindable operators. For example, we can now have
      `negate :: Int -> Bool` and
      `(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic
      is in tcSyntaxOp.
      
      This addresses tickets #11397, #11452, and #11458.
      
      Tests:
        typecheck/should_compile/{RebindHR,RebindNegate,T11397,T11458}
        th/T11452
      00cbbab3
    • Ömer Sinan Ağacan's avatar
      s/unLifted/unlifted for consistency · 4faa1a63
      Ömer Sinan Ağacan authored
      This was causing trouble as we had to remember when to use "unLifted"
      and when to use "unlifted".
      
      "unlifted" is used instead of "unLifted" as it's a single word.
      
      Reviewers: austin, hvr, goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1852
      4faa1a63
  29. 21 Jan, 2016 1 commit
    • Simon Peyton Jones's avatar
      Re-add missing kind generalisation · c572430c
      Simon Peyton Jones authored
      When splitting H98/GADT syntax in ConDecl we lost a key
      kind-generalisation step.
      
      I also renamed tcHsTyVarBndrs to tcExplicitTKBnders, by analogy
      with tcImplicitTkBndrs.
      
      This fixes Trac #11459.
      
      Merge to 8.0.
      c572430c
  30. 19 Jan, 2016 1 commit
    • niteria's avatar
      Check InScopeSet in substTy and provide substTyUnchecked · 9d33adb6
      niteria authored
      This adds sanity checks to `substTy` that implement:
      
      > when calling substTy subst ty it should be the case that the in-scope
      > set in the substitution is a superset of
      > * The free vars of the range of the substitution
      > * The free vars of ty minus the domain of the substitution
      
      and replaces violators with unchecked version. The violators were found
      by running the GHC test suite.
      
      This ensures that I can work on this incrementally and that what I fix won't
      be undone by some other change.
      
      It also includes a couple of fixes that I've already done.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, goldfire, simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1792
      
      GHC Trac Issues: #11371
      9d33adb6
  31. 18 Jan, 2016 2 commits
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      Summary:
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1784
      b8abd852
    • Simon Peyton Jones's avatar
      Implement scoped type variables in pattern synonyms · e2c7b7ee
      Simon Peyton Jones authored
      This fixes Trac #11351.   The implementation is pretty
      simple, happily.
      
      I took the opportunity to re-order the prov/req context
      in builder-ids, which was confusingly backwards.
      e2c7b7ee
  32. 07 Jan, 2016 1 commit
    • Simon Peyton Jones's avatar
      Use an Implication in 'deriving' error · 02c1c573
      Simon Peyton Jones authored
      Trac #11437 showed that erroneous constraints from a 'deriving'
      clause need to be wrapped in an Implication to properly scope
      their skolems.
      
      The main change is in TcDeriv.simplifyDeriv; the call to
      buildImplicationFor is new.
      02c1c573
  33. 31 Dec, 2015 1 commit