1. 07 Jan, 2016 8 commits
    • Gabor Greif's avatar
      Typos in docs and comments · c78fedde
      Gabor Greif authored
      c78fedde
    • Simon Peyton Jones's avatar
      Turn AThing into ATcTyCon, in TcTyThing · a5cea73c
      Simon Peyton Jones authored
      This change tidies up and simplifies (a bit) the knot-tying
      when kind-checking groups of type and class declarations.
      
      The trouble (shown by Trac #11356) was that we wanted an error message
      (a kind-mismatch) that involved a type mentioned a (AThing k), which
      blew up.
      
      Since we now seem to have TcTyCons, I decided to use them here.
      It's still not great, but it's easier to understand and more robust.
      a5cea73c
    • 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
    • Simon Peyton Jones's avatar
      Refactor simpl_top · dc970966
      Simon Peyton Jones authored
      simpl_top was being polluted with Safe Haskell stuff which was only
      used in one of its four calls.  This moves the Safe Haskell stuff
      to the place it is actually used
      dc970966
    • Simon Peyton Jones's avatar
      Inline solveTopConstraints · 29b46327
      Simon Peyton Jones authored
      It was only called in one place; easier to inline it
      29b46327
    • Simon Peyton Jones's avatar
      Comment wibble · 4dda4edb
      Simon Peyton Jones authored
      4dda4edb
    • Simon Peyton Jones's avatar
      Tidy up tidySkolemInfo · 290a553e
      Simon Peyton Jones authored
      Previously tidySkolemInfo used tidyOpenType, and returned a new
      TidyEnv.  But that's not needed any more, because all the skolems
      should be in scope in the constraint tree.
      
      I also removed a (now-unnecessary) field of UnifyForAllSkol
      290a553e
    • Simon Peyton Jones's avatar
      Spelling in a comment · 97c49e9e
      Simon Peyton Jones authored
      97c49e9e
  2. 06 Jan, 2016 2 commits
    • Jan Stolarek's avatar
      Change Template Haskell representation of GADTs. · cac0795a
      Jan Stolarek authored
      Previous representation of GADTs in TH was not expressive enough
      to express possible GADT return types. See #11341
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, bgamari
      
      Subscribers: thomie, RyanGlScott
      
      Differential Revision: https://phabricator.haskell.org/D1738
      
      GHC Trac Issues: #11341
      cac0795a
    • Ryan Scott's avatar
      Restore old GHC generics behavior vis-à-vis Fixity · 852b6030
      Ryan Scott authored
      Phab:D493 accidentally changed the way GHC generics looks up `Fixity`
      information when deriving `Generic` or `Generic1`. Before, a `Fixity` of
      `Infix` would be given only if a data constructor was declared infix,
      but now, `Infix` is given to any data constructor that has a fixity
      declaration (not to be confused with being declared infix!). This commit
      reverts back to the original behavior for consistency's sake.
      
      Fixes #11358.
      
      Test Plan: ./validate
      
      Reviewers: kosmikus, dreixel, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1740
      
      GHC Trac Issues: #11358
      852b6030
  3. 31 Dec, 2015 2 commits
  4. 30 Dec, 2015 2 commits
    • Gabor Greif's avatar
      Fix some typos · b0fa2864
      Gabor Greif authored
      b0fa2864
    • eir@cis.upenn.edu's avatar
      Fix #11305. · c06b46d0
      eir@cis.upenn.edu authored
      Summary:
      In the fallthrough case when doing a subsumption case, we
      need to deeply instantiate to remove any buried foralls in
      the "actual" type.
      
      Once this validates, please feel free to commit it; I may not
      have the chance to do this on Tuesday. Back in full action on
      Wed.
      
      Test Plan: ./validate, typecheck/should_compiler/T11305
      
      Reviewers: austin, bgamari, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1715
      
      GHC Trac Issues: #11305
      c06b46d0
  5. 26 Dec, 2015 3 commits
  6. 24 Dec, 2015 2 commits
    • eir@cis.upenn.edu's avatar
      Visible type application · 2db18b81
      eir@cis.upenn.edu authored
      This re-working of the typechecker algorithm is based on
      the paper "Visible type application", by Richard Eisenberg,
      Stephanie Weirich, and Hamidhasan Ahmed, to be published at
      ESOP'16.
      
      This patch introduces -XTypeApplications, which allows users
      to say, for example `id @Int`, which has type `Int -> Int`. See
      the changes to the user manual for details.
      
      This patch addresses tickets #10619, #5296, #10589.
      2db18b81
    • Simon Peyton Jones's avatar
      Refactoring only · 1af0d36b
      Simon Peyton Jones authored
      This moves code around to more sensible places.
      
      - Construction for CoAxiom is localised in FamInstEnv
      
      - orphNamesOfxx moves to CoreFVs
      
      - roughMatchTcs, instanceCantMatch moves to Unify
      
      - mkNewTypeCo moves from Coercion to FamInstEnv, and is
        renamed mkNewTypeCoAxiom, which makes more sense
      1af0d36b
  7. 23 Dec, 2015 4 commits
  8. 22 Dec, 2015 3 commits
    • Simon Peyton Jones's avatar
      Fix typechecking for pattern synonym signatures · f40e122b
      Simon Peyton Jones authored
      Various tickets have revealed bad shortcomings in the typechecking of
      pattern type synonyms.  Discussed a lot in (the latter part of)
      Trac #11224.
      
      This patch fixes the most complex issues:
      
      - Both parser and renamer now treat pattern synonyms as an
        ordinary LHsSigType.  Nothing special.  Hooray.
      
      - tcPatSynSig (now in TcPatSyn) typechecks the signature, and
        decomposes it into its pieces.
        See Note [Pattern synonym signatures]
      
      - tcCheckPatSyn has had a lot of refactoring.
        See Note [Checking against a pattern signature]
      
      The result is a lot tidier and more comprehensible.
      Plus, it actually works!
      
      NB: this patch doesn't actually address the precise
          target of #11224, namely "inlining pattern synonym
          does not preserve semantics".  That's an unrelated
          bug, with a separate patch.
      
      ToDo: better documentation in the user manual
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: goldfire, mpickering, thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D1685
      
      GHC Trac Issues: #11224
      f40e122b
    • Ryan Scott's avatar
      Rework Template Haskell's handling of strictness · f975b0b1
      Ryan Scott authored
      Currently, Template Haskell's treatment of strictness is not enough to
      cover all possible combinations of unpackedness and strictness. In
      addition, it isn't equipped to deal with new features (such as
      `-XStrictData`) which can change a datatype's fields' strictness during
      compilation.
      
      To address this, I replaced TH's `Strict` datatype with
      `SourceUnpackedness` and `SourceStrictness` (which give the programmer a
      more complete toolkit to configure a datatype field's strictness than
      just `IsStrict`, `IsLazy`, and `Unpack`). I also added the ability to
      reify a constructor fields' strictness post-compilation through the
      `reifyConStrictness` function.
      
      Fixes #10697.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, goldfire, bgamari, austin
      
      Reviewed By: goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1603
      
      GHC Trac Issues: #10697
      f975b0b1
    • Simon Peyton Jones's avatar
      Comments only, about coercion holes · ea3f733a
      Simon Peyton Jones authored
      Richard, pls take a look
      ea3f733a
  9. 21 Dec, 2015 7 commits
    • Jan Stolarek's avatar
      Add proper GADTs support to Template Haskell · eeecb864
      Jan Stolarek authored
      Until now GADTs were supported in Template Haskell by encoding them using
      normal data types.  This patch adds proper support for representing GADTs
      in TH.
      
      Test Plan: T10828
      
      Reviewers: goldfire, austin, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1465
      
      GHC Trac Issues: #10828
      eeecb864
    • Ömer Sinan Ağacan's avatar
    • Ryan Scott's avatar
      Encode strictness in GHC generics metadata · ee6fba89
      Ryan Scott authored
      This augments `MetaSel` with a `Bang` field, which gives generic
      programmers access to the following information about each field
      selector:
      
      * `SourceUnpackedness`: whether a field was marked `{-# NOUNPACK #-}`,
        `{-# UNPACK #-}`, or not
      * `SourceStrictness`: whether a field was given a strictness (`!`) or
        laziness (`~`) annotation
      * `DecidedStrictness`: what strictness GHC infers for a field during
        compilation, which may be influenced by optimization levels,
        `-XStrictData`, `-funbox-strict-fields`, etc.
      
      Unlike in Phab:D1603, generics does not grant a programmer the ability
      to "splice" in metadata, so there is no issue including
      `DecidedStrictness` with `Bang` (whereas in Template Haskell, it had to
      be split off).
      
      One consequence of this is that `MetaNoSel` had to be removed, since it
      became redundant. The `NoSelector` empty data type was also removed for
      similar reasons.
      
      Fixes #10716.
      
      Test Plan: ./validate
      
      Reviewers: dreixel, goldfire, kosmikus, austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1646
      
      GHC Trac Issues: #10716
      ee6fba89
    • msosn's avatar
      Warn about unused type variables in type families · eb7796f1
      msosn authored
      The warnings are enabled with the flag -fwarn-unused-matches, the same
      one that enables warnings on the term level.
      
      Identifiers starting with an underscore are now always parsed as type
      variables.  When the NamedWildCards extension is enabled, the renamer
      replaces those variables with named wildcards.
      
      An additional NameSet nwcs is added to LocalRdrEnv. It's used to keep
      names of the type variables that should be replaced with wildcards.
      
      While renaming HsForAllTy, when a name is explicitly bound it is removed
      from the nwcs NameSet. As a result, the renamer doesn't replace them in
      the quantifier body. (Trac #11098)
      
      Fixes #10982, #11098
      
      Reviewers: alanz, bgamari, hvr, austin, jstolarek
      
      Reviewed By: jstolarek
      
      Subscribers: goldfire, mpickering, RyanGlScott, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1576
      
      GHC Trac Issues: #10982
      eb7796f1
    • Alan Zimmerman's avatar
      Add Location to RdrName in FieldOcc · d8ed20c8
      Alan Zimmerman authored
      Summary:
      Post #11019, there have been some new instances of RdrName that are not
      located, in particular
      
      ```#!hs
      data FieldOcc name = FieldOcc { rdrNameFieldOcc  :: RdrName
                                    , selectorFieldOcc :: PostRn name name
                                    }
      
      data AmbiguousFieldOcc name
        = Unambiguous RdrName (PostRn name name)
        | Ambiguous   RdrName (PostTc name name)
        deriving (Typeable)
      ```
      Add locations to them
      
      Updates haddock submodule to match
      
      Test Plan: ./validate
      
      Reviewers: goldfire, hvr, bgamari, austin
      
      Reviewed By: hvr
      
      Subscribers: hvr, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1670
      
      GHC Trac Issues: #11258
      d8ed20c8
    • Ömer Sinan Ağacan's avatar
      TcTyClsDecls: Add a type annotation · 850710ab
      Ömer Sinan Ağacan authored
      850710ab
    • Ömer Sinan Ağacan's avatar
  10. 20 Dec, 2015 1 commit
  11. 18 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      tcCheckSatisfiability: less aggressive superclass expansion · ff752a1a
      Simon Peyton Jones authored
      In the pattern-match check we are looking for a proof of
      *unsatisfiablity* among a bunch of givens.  The unsat-ness might be
      hidden in the superclasses, so we must expand them.  But in the common
      case where the constraints are satisfiable, we don't want to expand
      a recursive superclass forever.
      
      This is all a bit arbitrary, but then the whole question is
      undecidable anyway.
      
      The bug in Trac #10592 comment:12 was that I expanded superclasses
      forever.  This patch fixes it.
      ff752a1a
  12. 17 Dec, 2015 5 commits
    • eir@cis.upenn.edu's avatar
      Fix tcTyClTyVars to handle SigTvs · ae86eb9f
      eir@cis.upenn.edu authored
      Previously, tcTyClTyVars required that the names of the LHsQTyVars
      matched up exactly with the names of the kind of the given TyCon.
      It now does a bit of matching up when necessary to relax this
      restriction.
      
      This commit enables a few tests that had previously been disabled.
      
      The shortcoming this addresses is discussed in #11203, but that
      ticket is not directly addressed here.
      
      Test case: polykinds/SigTvKinds, perf/compiler/T9872d
      ae86eb9f
    • Adam Gundry's avatar
      Reify DuplicateRecordFields by label, rather than by selector · 4b161c93
      Adam Gundry authored
      See `Note [Reifying field labels]` in `TcSplice`. This makes
      typical uses of TH work better with `DuplicateRecordFields`.
      If `reify` is called on the `Name` of a field label produced by
      the output of a previous `reify`, and there are multiple  fields
      with that label defined in the same module, it may fail with
      an ambiguity error.
      
      Test Plan:
      Added tests, and manually tested that this makes
      Aeson's `deriveJSON` avoid the `$sel:` prefixes.
      
      Reviewers: simonpj, goldfire, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1586
      
      GHC Trac Issues: #11103
      4b161c93
    • quchen's avatar
      Conditionally show plural "s" in warnings · 4f870f84
      quchen authored
      Redundant constraints and defaulting warnings had "constraint(s)" in
      their messages; the "s" is now conditional based on the number of things
      warned about.
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1647
      4f870f84
    • Ben Gamari's avatar
      TcTypeable: Don't use bogus fingerprints when suppress-uniques is enabled · 786d528e
      Ben Gamari authored
      Previously the Typeable implementation would intentionally create TyCon
      representations with bogus fingerprints to avoid fingerprints (which may
      change often) from leaking into test output. As pointed out by Richard
      in #10376 this is very bad as simply enabling a debug flag,
      `-dsuppress-uniques`, completely breaks the soundness of `Typeable`!
      
      This patch removes this behavior and replaces it with logic in the
      testsuite driver to filter out spurious changes due to Typeable
      representations.
      
      Test Plan: Validate
      
      Reviewers: austin, simonpj, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1629
      
      GHC Trac Issues: #10376
      786d528e
    • Simon Marlow's avatar
      Remote GHCi, -fexternal-interpreter · 4905b83a
      Simon Marlow authored
      Summary:
      (Apologies for the size of this patch, I couldn't make a smaller one
      that was validate-clean and also made sense independently)
      
      (Some of this code is derived from GHCJS.)
      
      This commit adds support for running interpreted code (for GHCi and
      TemplateHaskell) in a separate process.  The functionality is
      experimental, so for now it is off by default and enabled by the flag
      -fexternal-interpreter.
      
      Reaosns we want this:
      
      * compiling Template Haskell code with -prof does not require
        building the code without -prof first
      
      * when GHC itself is profiled, it can interpret unprofiled code, and
        the same applies to dynamic linking.  We would no longer need to
        force -dynamic-too with TemplateHaskell, and we can load ordinary
        objects into a dynamically-linked GHCi (and vice versa).
      
      * An unprofiled GHCi can load and run profiled code, which means it
        can use the stack-trace functionality provided by profiling without
        taking the performance hit on the compiler that profiling would
        entail.
      
      Amongst other things; see
      https://ghc.haskell.org/trac/ghc/wiki/RemoteGHCi for more details.
      
      Notes on the implementation are in Note [Remote GHCi] in the new
      module compiler/ghci/GHCi.hs.  It probably needs more documenting,
      feel free to suggest things I could elaborate on.
      
      Things that are not currently implemented for -fexternal-interpreter:
      
      * The GHCi debugger
      * :set prog, :set args in GHCi
      * `recover` in Template Haskell
      * Redirecting stdin/stdout for the external process
      
      These are all doable, I just wanted to get to a working validate-clean
      patch first.
      
      I also haven't done any benchmarking yet.  I expect there to be slight hit
      to link times for byte code and some penalty due to having to
      serialize/deserialize TH syntax, but I don't expect it to be a serious
      problem.  There's also lots of low-hanging fruit in the byte code
      generator/linker that we could exploit to speed things up.
      
      Test Plan:
      * validate
      * I've run parts of the test suite with
      EXTRA_HC_OPTS=-fexternal-interpreter, notably tests/ghci and tests/th.
      There are a few failures due to the things not currently implemented
      (see above).
      
      Reviewers: simonpj, goldfire, ezyang, austin, alanz, hvr, niteria, bgamari, gibiansky, luite
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1562
      4905b83a