1. 09 May, 2017 1 commit
    • Ben Gamari's avatar
      Treat banged bindings as FunBinds · 37299536
      Ben Gamari authored
      This reworks the HsSyn representation to make banged variable patterns
      (e.g. !x = e) be represented as FunBinds instead of PatBinds, adding a flag to
      FunRhs to record the bang.
      
      Fixes #13594.
      
      Reviewers: austin, goldfire, alanz, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3525
      37299536
  2. 08 May, 2017 1 commit
  3. 04 May, 2017 4 commits
    • Ben Gamari's avatar
      TcTypeable: Simplify · c8e4d4b3
      Ben Gamari authored
      Simon pointed out that the zonk of the tyConKinds was redundant as tycon kinds
      will never contain mutable variables. This allows us to remove tycon_kind.
      Add a few commments clarifying the need to bring TyCon binders into scope before
      typechecking bindings.
      c8e4d4b3
    • Matthew Pickering's avatar
      Implement sequential name lookup properly · 1829d265
      Matthew Pickering authored
      Previously we would run all the monadic actions and then
      combine their results. This caused problems if later actions
      raised errors but earlier lookups suceeded. We only want to run later
      lookups if the earlier ones fail.
      
      Fixes #13622
      
      Reviewers: RyanGlScott, austin, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, rwbarton, thomie
      
      GHC Trac Issues: #13622
      
      Differential Revision: https://phabricator.haskell.org/D3515
      1829d265
    • Simon Peyton Jones's avatar
      2a097001
    • Simon Peyton Jones's avatar
      Deal with exceptions in dsWhenNoErrs · e7701976
      Simon Peyton Jones authored
      Gracious me.  Ever since this patch
      
        commit 37445780
        Author: Jan Stolarek <jan.stolarek@p.lodz.pl>
        Date:   Fri Jul 11 13:54:45 2014 +0200
      
            Injective type families
      
      TcRnMonad.askNoErrs has been wrong. It looked like this
      
         askNoErrs :: TcRn a -> TcRn (a, Bool)
         askNoErrs m
          = do { errs_var <- newTcRef emptyMessages
               ; res  <- setErrsVar errs_var m
               ; (warns, errs) <- readTcRef errs_var
               ; addMessages (warns, errs)
               ; return (res, isEmptyBag errs) }
      
      The trouble comes if 'm' throws an exception in the TcRn monad.
      Then 'errs_var is never read, so any errors are simply lost.
      
      This mistake was then propgated into DsMonad.dsWhenNoErrs, where
      it gave rise to Trac #13642.
      
      Thank to Ryan for narrowing it down so sharply.
      
      I did some refactoring, as usual.
      e7701976
  4. 03 May, 2017 2 commits
  5. 01 May, 2017 2 commits
  6. 29 Apr, 2017 1 commit
  7. 28 Apr, 2017 4 commits
  8. 18 Apr, 2017 1 commit
  9. 13 Apr, 2017 3 commits
    • Matthías Páll Gissurarson's avatar
      Fix typo in TcErrors.hs · 13131ce9
      Matthías Páll Gissurarson authored
      This fixes a very simple typo in TcErrors.hs. I hope this is small
      enough in scope to be accepted through GitHub.
      13131ce9
    • Simon Peyton Jones's avatar
      Remove dead quantifyTyVars · fbb27d77
      Simon Peyton Jones authored
      This patch
      
      * removes a function TcMType.quantifyTyVars
        that was never called
      
      * renames quantifyZonkedTyVars to quantifyTyVars
      
      Plus a few comments.  No functional change at all
      fbb27d77
    • Simon Peyton Jones's avatar
      Yet more work on TcSimplify.simplifyInfer · 0ae72512
      Simon Peyton Jones authored
      The proximate cause for this patch is Trac #13482, which pointed out
      further subtle interactions between
         - Inferring the most general type of a function
         - A partial type signature for that function
      
      That led me into /further/ changes to the shiny new stuff in
      TcSimplify.simplifyInfer, decideQuantification, decideMonoTyVars,
      and related functions.
      
      Happily, I was able to make some of it quite a bit simpler,
      notably the bit about promoting free tyvars.  I'm happy with
      the result.
      
      Moreover I fixed Trac #13524 at the same time.  Happy days.
      0ae72512
  10. 12 Apr, 2017 2 commits
  11. 11 Apr, 2017 1 commit
  12. 06 Apr, 2017 6 commits
    • Simon Peyton Jones's avatar
      Be less aggressive about fragile-context warrnings · 65b185d4
      Simon Peyton Jones authored
      In the implementation of WarnSimplifiableClassConstraints, be
      less aggressive about reporting a problem. We were complaining
      about a "fragile" case that in fact was not fragile.
      
      See Note [Simplifiable given constraints] in TcValidity.
      
      This fixes Trac #13526.
      65b185d4
    • Simon Peyton Jones's avatar
      Comments only · 2ab7f626
      Simon Peyton Jones authored
      2ab7f626
    • Simon Peyton Jones's avatar
      Yet another attempt at inferring the right quantification · bac95f9d
      Simon Peyton Jones authored
      TcSimplify.decideQuantification is truly a tricky function!
      Trac #13509 showed that we were being over-eager with defaulting
      of runtime-rep variables (levity polymorphism), which meant that
      a program was wrongly rejected, and with a very odd error message
      (c.f. Trac #13530)
      
      I spent an unreasonably long time figuring out how to fix this
      in a decent way, and ended up with a major refactoring of
      decideQuantification, with a kock-on effect in simplifyInfer.
      
      It is at least a bit more comprehensible now; but I still
      can't say I like it.
      bac95f9d
    • Simon Peyton Jones's avatar
      Comments and eta expand only · c90f8334
      Simon Peyton Jones authored
      c90f8334
    • Simon Peyton Jones's avatar
      Add a missing addDeferredBinding · 2f9f1f86
      Simon Peyton Jones authored
      I'd forgotten to add deferred bindings for user type
      errors.  Fixes Trac #13487.
      2f9f1f86
    • Simon Peyton Jones's avatar
      Don't report fundep wanted/wanted errors · 48daaaf0
      Simon Peyton Jones authored
      This makes GHC drop derived FunDep errors when they
      are come from wanted/wanted interactions.  Much along
      the lines of "don't rewrite wanteds with wanteds".
      
      See TcRnTypes Note [Dropping derived constraints]
      and the new code in isDroppableDerivedLoc.
      
      Fixes Trac #13506.
      48daaaf0
  13. 05 Apr, 2017 2 commits
  14. 02 Apr, 2017 5 commits
  15. 01 Apr, 2017 1 commit
    • David Feuer's avatar
      Don't derive showList · 83ac4624
      David Feuer authored
      There's no obvious reason to derive the definition of `showList`,
      manually inlining the default definition. Let's just use
      the default definition in the usual manner.
      
      Garbage collect a few unused `RdrNames` from `PrelNames`:
      `showList`, `showList__`, and `/=`.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: RyanGlScott, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3403
      83ac4624
  16. 31 Mar, 2017 1 commit
    • Ben Gamari's avatar
      Clean up coreView/tcView. · 6575f4b6
      Ben Gamari authored
      In Core, Constraint should be considered fully equal to
      TYPE LiftedRep, in all ways. Accordingly, coreView should
      unwrap Constraint to become TYPE LiftedRep. Of course, this
      would be a disaster in the type checker.
      
      So, where previously we used coreView in both the type checker
      and in Core, we now have coreView and tcView, which differ only
      in their treatment of Constraint.
      
      Historical note: once upon a past, we had tcView distinct from
      coreView. Back then, it was because newtypes were unwrapped in
      Core but not in the type checker. The distinction is back, but
      for a different reason than before.
      
      This had a few knock-on effects:
      
       * The Typeable solver must explicitly handle Constraint to ensure
         that we produce the correct evidence.
      
       * TypeMap now respects the Constraint/Type distinction
      
      Finished by: bgamari
      
      Test Plan: ./validate
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3316
      6575f4b6
  17. 30 Mar, 2017 2 commits
    • David Feuer's avatar
      Deriving for phantom and empty types · 69f070d8
      David Feuer authored
      Make `Functor`, `Foldable`, and `Traversable` take advantage
      of the case where the type parameter is phantom. In this case,
      
      * `fmap _ = coerce`
      * `foldMap _ _ = mempty`
      * `traverse _ x = pure (coerce x)`
      
      For the sake of consistency and especially simplicity, make other types
      with no data constructors behave the same:
      
      * `fmap _ x = case x of`
      * `foldMap _ _ = mempty`
      * `traverse _ x = pure (case x of)`
      
      Similarly, for `Generic`,
      
      * `to x = case x of`
      * `from x = case x of`
      
      Give all derived methods for types without constructors appropriate
      arities. For example,
      
      ```
          compare _ _ = error ...
      ```
      
      rather than
      
      ```
          compare = error ...
      ```
      
      Fixes #13117 and #13328
      
      Reviewers: austin, bgamari, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: ekmett, RyanGlScott, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3374
      69f070d8
    • Gabor Greif's avatar
      Typos in comments [ci skip] · ff7094e5
      Gabor Greif authored
      ff7094e5
  18. 29 Mar, 2017 1 commit
    • Matthías Páll Gissurarson's avatar
      Show valid substitutions for typed holes · 26c95f46
      Matthías Páll Gissurarson authored
      The idea is to implement a mechanism similar to PureScript, where they
      suggest which identifiers in scope would fit the given hole. In
      PureScript, they use subsumption (which is what we would like here as
      well). For subsumption, we would have to check each type in scope
      whether the hole is a subtype of the given type, but that would require
      `tcSubType` and constraint satisfiability checking. Currently,
      `TcSimplify` uses a lot of functions from `TcErrors`, so that would
      require more of a rewrite, I will hold on with that for now, and submit
      the more simpler type equality version.
      
      As an example, consider
      
      ```
      ps :: String -> IO ()
      ps = putStrLn
      
      ps2 :: a -> IO ()
      ps2 _ = putStrLn "hello, world"
      
      main :: IO ()
      main = _ "hello, world"
      ```
      
      The results would be something like
      
      ```
          • Found hole: _ :: [Char] -> IO ()
          • In the expression: _
            In a stmt of a 'do' block: _ "hello, world"
            In the expression:
              do _ "hello, world"
          • Relevant bindings include
              main :: IO () (bound at test.hs:13:1)
              ps :: String -> IO () (bound at test.hs:7:1)
              ps2 :: forall a. a  -> IO () (bound at test.hs:10:1)
            Valid substitutions include
              putStrLn :: String
                          -> IO () (imported from ‘Prelude’ at
      test.hs:1:1-14
                                    (and originally defined in
      ‘System.IO’))
              putStr :: String
                        -> IO () (imported from ‘Prelude’ at
      test.hs:1:1-14
                                  (and originally defined in ‘System.IO’))
      ```
      
      We'd like here for ps2 to be suggested as well, but for that we require
      subsumption.
      
      Reviewers: austin, bgamari, dfeuer, mpickering
      
      Reviewed By: dfeuer, mpickering
      
      Subscribers: mpickering, Wizek, dfeuer, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3361
      26c95f46