1. 27 Oct, 2018 1 commit
    • mayac's avatar
      More explicit foralls (GHC Proposal 0007) · 512eeb9b
      mayac authored
      Allow the user to explicitly bind type/kind variables in type and data
      family instances (including associated instances), closed type family
      equations, and RULES pragmas. Follows the specification of GHC
      Proposal 0007, also fixes #2600. Advised by Richard Eisenberg.
      
      This modifies the Template Haskell AST -- old code may break!
      
      Other Changes:
      - convert HsRule to a record
      - make rnHsSigWcType more general
      - add repMaybe to DsMeta
      
      Includes submodule update for Haddock.
      
      Test Plan: validate
      
      Reviewers: goldfire, bgamari, alanz
      
      Subscribers: simonpj, RyanGlScott, goldfire, rwbarton,
                   thomie, mpickering, carter
      
      GHC Trac Issues: #2600, #14268
      
      Differential Revision: https://phabricator.haskell.org/D4894
      512eeb9b
  2. 26 Oct, 2018 4 commits
    • Simon Jakobi's avatar
      Remove redundant SOURCE import · 23956b2a
      Simon Jakobi authored
      23956b2a
    • Simon Peyton Jones's avatar
      Fix nasty bug in the type free-var finder, at last · 503514b9
      Simon Peyton Jones authored
      Consider the type
        forall k. b -> k
      where
        b :: k -> Type
      
      Here the 'k' in b's kind must be a different 'k' to the forall k,
      because 'b' is free in the expression.  So we must return 'k'
      among the free vars returned from tyCoVarsOfType applied that
      type.  But we weren't.
      
      This is an outright bug, although we don't have a program that
      fails because of it.
      
      It's easy to fix, too: see TyCoRep
        Note [Closing over free variable kinds]
      
      This fix has been in the pipeline for ages because it fell into
      the Trac #14880 swamp.  But this patch nails it.
      503514b9
    • Simon Peyton Jones's avatar
      Fix generalisation for type constructors · 4de4b225
      Simon Peyton Jones authored
      Fixing the way that we close-over-kinds when taking the
      free vars of a type revealed that the way we generalise
      type constructors was a bit wrong.
      
      This fixes it.  See TcTyClDecls
      Note [Generalisation for type constructors]
      4de4b225
    • Simon Peyton Jones's avatar
      De-monadise the 'extract' functions in RnTypes · e6bf96c9
      Simon Peyton Jones authored
      As Trac #15765 says, Once upon a time, the extract functions
      at the bottom of RnTypes were pure. Then, along came -XTypeInType,
      which needed to do a check in these functions for users mixing
      type variables with kind variables.
      
      Now, however, with -XTypeInType gone again, we no longer
      do this check. Thus, there is no reason to keep these
      functions monadic.
      e6bf96c9
  3. 25 Oct, 2018 9 commits
  4. 24 Oct, 2018 13 commits
    • Simon Peyton Jones's avatar
      Remove unnecessary free-var-set deletion · 9aaa8971
      Simon Peyton Jones authored
      In TcSimplify.neededEvVars, in add_implic_seeds we were
      deleting the 'givens'; but they are already deleted, so
      this is a no-op.  This patch just remove the redundant
      delete.
      9aaa8971
    • Simon Peyton Jones's avatar
      Wibble report a wanted · ecfe38ef
      Simon Peyton Jones authored
      ecfe38ef
    • Simon Peyton Jones's avatar
      Add HasDebugCallStack to ctEvCoecion · e2ca1072
      Simon Peyton Jones authored
      This is a debug-only change
      e2ca1072
    • Simon Peyton Jones's avatar
      Report a Wanted error even if there are Given ones · 6b1102e2
      Simon Peyton Jones authored
      We suppress some Given errors; see Note [Given errors]
      in TcErrors.  But we must be careful not to suppress
      Wanted errors because of the presence of these Given
      errors -- else we might allow compilation to bogusly
      proceed
      
      The rubber hits the road in TcRnTypes.insolubleCt,
      where we don't want to treat Givens as insoluble,
      nor (and this is the new bit) Deriveds that arise
      from Givens.  See Note [Given insolubles] in TcRnTypes.
      
      This fixes #15767.
      6b1102e2
    • Simon Peyton Jones's avatar
      Don't print out undefined coercions · 7d903644
      Simon Peyton Jones authored
      A debug-print was trying to print the coercion returned
      by the flattener.  But that coercion can be undefined
      in the case of Derived constraints.  Because we might
      rewrite it with [D] a ~ ty, and there is no evidence
      for that.
      
      Solution: don't attempt to print the coercion.
      7d903644
    • Simon Peyton Jones's avatar
      Solve equalities in a pattern signature · 7ea714cd
      Simon Peyton Jones authored
      Trac #15694 showed that we were forgetting to solve
      the equalities of a pattern signature until too late.
      
      Result: WARNINGs and a panic:
        "Type-correct unfilled coercion hole"
      7ea714cd
    • Simon Peyton Jones's avatar
      Refactor the treatment of predicate types · 0faf7fd3
      Simon Peyton Jones authored
      Trac #15648 showed that GHC was a bit confused about the
      difference between the types for
      
      * Predicates
      * Coercions
      * Evidence (in the typechecker constraint solver)
      
      This patch cleans it up. See especially Type.hs
      Note [Types for coercions, predicates, and evidence]
      
      Particular changes
      
      * Coercion types (a ~# b) and (a ~#R b) are not predicate types
        (so isPredTy reports False for them) and are not implicitly
        instantiated by the type checker.  This is a real change, but
        it consistently reflects that fact that (~#) and (~R#) really
        are different from predicates.
      
      * isCoercionType is renamed to isCoVarType
      
      * During type inference, simplifyInfer, we do /not/ want to infer
        a constraint (a ~# b), because that is no longer a predicate type.
        So we 'lift' it to (a ~ b). See TcType
        Note [Lift equality constaints when quantifying]
      
      * During type inference for pattern synonyms, we need to 'lift'
        provided constraints of type (a ~# b) to (a ~ b).  See
        Note [Equality evidence in pattern synonyms] in PatSyn
      
      * But what about (forall a. Eq a => a ~# b)? Is that a
        predicate type?  No -- it does not have kind Constraint.
        Is it an evidence type?  Perhaps, but awkwardly so.
      
        In the end I decided NOT to make it an evidence type,
        and to ensure the the type inference engine never
        meets it.  This made me /simplify/ the code in
        TcCanonical.makeSuperClasses; see TcCanonical
        Note [Equality superclasses in quantified constraints]
      
        Instead I moved the special treatment for primitive
        equality to TcInteract.doTopReactOther.  See TcInteract
        Note [Looking up primitive equalities in quantified constraints]
      
        Also see Note [Evidence for quantified constraints] in Type.
      
        All this means I can have
           isEvVarType ty = isCoVarType ty || isPredTy ty
        which is nice.
      
      All in all, rather a lot of work for a small refactoring,
      but I think it's a real improvement.
      0faf7fd3
    • Simon Peyton Jones's avatar
      Improve output from -ddump-types · 321bc1a6
      Simon Peyton Jones authored
      This patch makes a number of improvements to the output
      generated by -ddump-types
      
      * Prints data constructor separately
      * Omits empty chunks of output
      
      I was driven initially by the unhelpful existing output for
      data constructors, but ended up doing some refactoring.
      
      Lots of error message wibbles, but nothing significant.
      Certainly no change in user behaviour.
      
      (NB: It is just possible that I have failed to cleanly
           separate this patch from the next one, about
           isPredTy and friends.)
      321bc1a6
    • Simon Peyton Jones's avatar
      Comments and white space · 41115401
      Simon Peyton Jones authored
      41115401
    • Ryan Scott's avatar
      Fix #15792 by not reifying invisible arguments in AppTys · bfd93f90
      Ryan Scott authored
      Summary:
      The `reifyType` function in `TcSplice` is carefully designed
      to avoid reifying visible arguments to `TyConApp`s. However, the same
      care was not given towards the `AppTy` case, which lead to #15792.
      
      This patch changes to the `AppTy` case of `reifyType` so that it
      consults the kind of the function type to determine which of the
      argument types are invisible (and therefore should be dropped) during
      reification. This required crafting a variant of `tyConArgFlags`,
      which I dubbed `appTyArgFlags`, that accept an arbitrary function
      `Type` instead of a `TyCon`.
      
      Test Plan: make test TEST=T15792
      
      Reviewers: goldfire, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, carter
      
      GHC Trac Issues: #15792
      
      Differential Revision: https://phabricator.haskell.org/D5252
      bfd93f90
    • Ryan Scott's avatar
      Keep top-level names in typed TH quotes alive · bb835c96
      Ryan Scott authored
      Summary:
      When renaming untyped TH quotes, some care is taken to
      ensure that uses of top-level names in quotes do not have their
      bindings discarded during desugaring. The same care was not applied
      to typed TH quotes, so this patch brings the two into sync.
      
      Test Plan: make test TEST=T15783
      
      Reviewers: bgamari, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: mpickering, rwbarton, carter
      
      GHC Trac Issues: #15783
      
      Differential Revision: https://phabricator.haskell.org/D5248
      bb835c96
    • Ryan Scott's avatar
      Fix #15781 by using ktypedocs on type synonym RHSes · 79c641de
      Ryan Scott authored
      Summary:
      This is a follow-up to D5173, which permitted
      unparenthesized kind signatures in certain places. One place that
      appeared to be overlooked was the right-hand sides of type synonyms,
      which this patch addresses by introducing a `ktypedoc` parser
      production (which is to `ctypdoc` as `ktype` is to `ctype`) and
      using it in the right place.
      
      Test Plan: make test TEST="KindSigs T15781"
      
      Reviewers: harpocrates, bgamari
      
      Reviewed By: harpocrates
      
      Subscribers: rwbarton, mpickering, carter
      
      GHC Trac Issues: #15781
      
      Differential Revision: https://phabricator.haskell.org/D5245
      79c641de
    • Alec Theriault's avatar
      Trigger multiline mode in GHCi on '\case' (#13087) · eaf15934
      Alec Theriault authored
      Summary:
      In ALR, 'ITlcase' should expect an opening curly. This is probably a forgotten
      edge case in ALR, since `maybe_layout` (which handles the non-ALR layout)
      already deals with the 'ITlcase' token properly.
      
      Test Plan: make TEST=T10453 && make TEST=T13087
      
      Reviewers: bgamari, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, carter
      
      GHC Trac Issues: #10453, #13087
      
      Differential Revision: https://phabricator.haskell.org/D5236
      eaf15934
  5. 23 Oct, 2018 4 commits
  6. 22 Oct, 2018 2 commits
  7. 20 Oct, 2018 2 commits
  8. 19 Oct, 2018 1 commit
    • Ningning Xie's avatar
      Adding almost devoid check for covar in ForAllCo · 879db559
      Ningning Xie authored
      Summary:
      For the sake of consistency of the dependent core, there is a restriction on
      where a coercion variable can appear in ForAllCo: the coercion variable can
      appear nowhere except in coherence coercions.
      
      Currently this restriction is missing in Core. The goal of this patch is to add
      the missing restriction.
      
      After discussion, we decide: coercion variables can appear nowhere except in
      `GRefl` and `Refl`. Relaxing the restriction to include `Refl` should not break
      consistency, we premuse.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15757
      
      Differential Revision: https://phabricator.haskell.org/D5231
      879db559
  9. 17 Oct, 2018 3 commits
  10. 15 Oct, 2018 1 commit