1. 30 Mar, 2017 1 commit
    • 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
  2. 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
  3. 27 Mar, 2017 2 commits
  4. 24 Mar, 2017 2 commits
  5. 19 Mar, 2017 2 commits
  6. 17 Mar, 2017 1 commit
  7. 14 Mar, 2017 3 commits
    • Ryan Scott's avatar
      Allow associated types to pattern-match in non-class-bound variables · 67345ccf
      Ryan Scott authored
      Summary:
      After 8136a5cb (#11450), if you have
      a class with an associated type:
      
      ```
      class C a where
        type T a b
      ```
      
      And you try to create an instance of `C` like this:
      
      ```
      instance C Int where
        type T Int Char = Bool
      ```
      
      Then it is rejected, since you're trying to instantiate the variable ``b`` with
      something other than a type variable. But this restriction proves quite
      onerous in practice, as it prevents you from doing things like this:
      
      ```
      class C a where
        type T a (b :: Identity c) :: c
      
      instance C Int where
        type T Int ('Identity x) = x
      ```
      
      You have to resort to an auxiliary type family in order to define this now,
      which becomes extremely tiring. This lifts this restriction and fixes #13398,
      in which it was discovered that adding this restriction broke code in the wild.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, bgamari, austin
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3302
      67345ccf
    • Ryan Scott's avatar
      Further document :type +v's role in analyzing -XTypeApplications in GHCi · b335f506
      Ryan Scott authored
      Summary:
      The section on `-XTypeApplications` in the users' guide isn't terribly
      clear on how to view the visibility of a function type signature's type
      variables in GHCi properly (i.e., using the `:type +v` GHCi command). This
      adds some more exposition that demonstrates how to use `:type +v` (and why you
      don't want to use `:type`).
      
      Fixes #13401.
      
      Test Plan: Eyeball it
      
      Reviewers: bgamari, austin, goldfire, crockeea
      
      Reviewed By: goldfire, crockeea
      
      Subscribers: rwbarton, thomie, crockeea
      
      Differential Revision: https://phabricator.haskell.org/D3310
      b335f506
    • Gabor Greif's avatar
      Typos in manual and comments · 50512c6b
      Gabor Greif authored
      50512c6b
  8. 13 Mar, 2017 1 commit
  9. 11 Mar, 2017 1 commit
    • Ryan Scott's avatar
      Observe #13267 in release notes · 740ecda3
      Ryan Scott authored
      I noticed some code in the wild that broke due to the validity checking
      introduced in #13267, so we should be proactive and warn about it in the 8.2
      release notes.
      740ecda3
  10. 06 Mar, 2017 2 commits
  11. 03 Mar, 2017 2 commits
    • rwbarton's avatar
      Don't allow orphan COMPLETE pragmas (#13349) · fce3d37c
      rwbarton authored
      We might support them properly in the future, but for now it's simpler
      to disallow them.
      
      Test Plan: validate
      
      Reviewers: mpickering, austin, bgamari, simonpj
      
      Reviewed By: mpickering, simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3243
      fce3d37c
    • Simon Marlow's avatar
      Add -fwhole-archive-hs-libs · a6874e54
      Simon Marlow authored
      We're building a demo to show how to hot-swap Haskell code in a
      running process, and unfortunately it wasn't possible to convince GHC
      to generate the correct linker command line without this extra knob.
      
      Test Plan:
      Tested it on a hot-swapping demo (which is not released yet, but will
      be shortly)
      
      Reviewers: niteria, austin, erikd, JonCoens, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3136
      a6874e54
  12. 02 Mar, 2017 3 commits
  13. 28 Feb, 2017 1 commit
    • Ben Gamari's avatar
      rts: Allow profile output path to be specified on RTS command line · db2a6676
      Ben Gamari authored
      This introduces a RTS option, -po, which allows the user to override the stem
      used to form the output file names of the heap profile and cost center summary.
      
      It's a bit unclear to me whether this is really the interface we want.
      Alternatively we could just allow the user to specify the `.hp` and `.prof` file
      names separately. This would arguably be a bit more straightforward and would
      allow the user to name JSON output with an appropriate `.json` suffix if they so
      desired. However, this would come at the cost of taking more of the option
      space, which is a somewhat precious commodity.
      
      Test Plan: Validate, try using `-po` RTS option
      
      Reviewers: simonmar, austin, erikd
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3182
      db2a6676
  14. 27 Feb, 2017 2 commits
    • Simon Peyton Jones's avatar
      Add -fspec-constr-keen · 4f38fa10
      Simon Peyton Jones authored
      I discovered that the dramatic imprvoement in perf/should_run/T9339
      with the introduction of join points was really rather a fluke, and
      very fragile.
      
      The real problem (see Note [Making SpecConstr keener]) is that
      SpecConstr wasn't specialising a function even though it was applied
      to a freshly-allocated constructor.  The paper describes plausible
      reasons for this, but I think it may well be better to be a bit more
      aggressive.
      
      So this patch add -fspec-constr-keen, which makes SpecConstr a bit
      keener to specialise, by ignoring whether or not the argument
      corresponding to a call pattern is scrutinised in the function body.
      Now the gains in T9339 should be robust; and it might even be a
      better default.
      
      I'd be interested in what happens if we switched on -fspec-constr-keen
      with -O2.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3186
      4f38fa10
    • Edward Z. Yang's avatar
      Subtyping for roles in signatures. · 923d7ca2
      Edward Z. Yang authored
      
      
      Summary:
      This commit implements the plan in #13140:
      
      * Today, roles in signature files default to representational. Let's change the
        default to nominal, as this is the most flexible implementation side. If a
        client of the signature needs to coerce with a type, the signature can be
        adjusted to have more stringent requirements.
      
      * If a parameter is declared as nominal in a signature, it can be implemented
        by a data type which is actually representational.
      
      * When merging abstract data declarations, we take the smallest role for every
        parameter. The roles are considered fix once we specify the structure of an
        ADT.
      
      * Critically, abstract types are NOT injective, so we aren't allowed to
        make inferences like "if T a ~R T b, then a ~N b" based on the nominal
        role of a parameter in an abstract type (this would be unsound if the
        parameter ended up being phantom.)  This restriction is similar to the
        restriction we have on newtypes.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, austin, goldfire
      
      Subscribers: goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3123
      923d7ca2
  15. 26 Feb, 2017 3 commits
  16. 24 Feb, 2017 1 commit
  17. 23 Feb, 2017 4 commits
  18. 20 Feb, 2017 2 commits
    • Simon Peyton Jones's avatar
      Change -dppr-ticks to -dsuppress-ticks · 2d5be63d
      Simon Peyton Jones authored
      I spent about two hours today hunting fruitlessly for a simplifier
      bug (when fixing Trac #13255), only to find that it was caused by
      -ddump-X silently suppressing all ticks in Core.
      
      I think this has happened to me once before.
      
      So I've changed to make tick-printing on by default (like coercions,
      etc), with a flag -dsuppress-ticks (like -dsuppress-coercions) to
      suppress them.
      
      Blargh.
      
      -dppr-ticks is still there, but deprecated.
      2d5be63d
    • Gabor Greif's avatar
      Typos in manual, tests and comments · 0aafe519
      Gabor Greif authored
      0aafe519
  19. 17 Feb, 2017 1 commit
    • Edward Z. Yang's avatar
      Improvements/bugfixes to signature reexport handling. · fd2d5b6d
      Edward Z. Yang authored
      
      
      Summary:
      A number of changes:
      
      - Keep the TcGblEnv from typechecking the local signature
        around when we do merging.  In particular, we setup
        tcg_imports and tcg_rdr_env according to the local
        signature.  This improves our error output (for example,
        see bkpfail04) and also fixes a bug with reexporting
        modules in signatures (see bkpreex07)
      
      - Fix a bug in thinning, where if we had signature A(module A),
        this previously would have *thinned out* all of the inherited
        signatures.  Now we treat every inherited signature as having
        come from an import like "import A", so a module A reexport
        will pick them up.
      
      - Recompilation checking now keeps track of dependent source files
        of the source signature; previously we forgot to retain this
        info.
      
      There's a manual update too.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3133
      fd2d5b6d
  20. 15 Feb, 2017 1 commit
  21. 14 Feb, 2017 2 commits
    • vivid-synth's avatar
      Allow type defaulting for multi-param type classes with ExtendedDefaultRules · c3bbd1af
      vivid-synth authored
      Expressions like the following will now typecheck:
      
      ```
          data A x = A deriving Show
      
          class ToA a x where
             toA :: a -> A x
      
          instance ToA Integer x where
             toA _ = A
      
          main = print (toA 5 :: A Bool)
      ```
      
      The new defaulting rules are
      
      Find all the unsolved constraints. Then:
      
      * Find those that have exactly one free type variable, and partition
        that subset into groups that share a common type variable `a`.
      * Now default `a` (to one of the types in the default list) if at least
        one of the classes `Ci` is an interactive class
      
      Reviewers: goldfire, bgamari, austin, mpickering, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: mpickering, simonpj, goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2822
      c3bbd1af
    • Tamar Christina's avatar
      Expand list of always loaded Windows shared libs · 04f67c99
      Tamar Christina authored
      When the `GCC` driver envokes the pipeline a `SPEC` is used to determine
      how to configure the compiler and which libraries to pass along.
      
      For Windows/mingw, this specfile is
      https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/mingw32.h
      
      This expands the list of base DLLs with the ones that GCC always links,
      and adds extra sibling dlls of `stdc++` in case it is linked in.
      
      Following D3028 this patch only needs to load the always load only the
      top level individual shared libs.
      
      Test Plan: ./validate
      
      Reviewers: RyanGlScott, austin, bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: RyanGlScott, thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D3029
      04f67c99
  22. 13 Feb, 2017 2 commits