| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Triggered by the changes in #13677, I ended up doing a bit of
refactoring in type pretty-printing.
* We were using TyOpPrec and FunPrec rather inconsitently, so
I made it consisent.
* That exposed the fact that we were a bit undecided about whether
to print
a + b -> c + d vs (a+b) -> (c+d)
and similarly
a ~ [b] => blah vs (a ~ [b]) => blah
I decided to make TyOpPrec and FunPrec compare equal
(in BasicTypes), so (->) is treated as equal precedence with
other type operators, so you get the unambiguous forms above,
even though they have more parens.
We could readily reverse this decision.
See Note [Type operator precedence] in BasicTypes
* I fixed a bug in pretty-printing of HsType where some
parens were omitted by mistake.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
The script I used is included as testsuite/driver/kill_extra_files.py,
though at this point it is for mostly historical interest.
Some of the tests in libraries/hpc relied on extra_files.py, so this
commit includes an update to that submodule.
One test in libraries/process also relies on extra_files.py, but we
cannot update that submodule so easily, so for now we special-case it
in the test driver.
|
|
|
|
|
| |
Some of the *.T files were in libraries/hpc, so this contains an
update to that submodule.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Using the default definition of `<$` for derived `Functor`
instance is very bad for recursive data types. Derive
the definition instead.
Fixes #13218
Reviewers: austin, bgamari, RyanGlScott
Reviewed By: RyanGlScott
Subscribers: RyanGlScott, thomie
Differential Revision: https://phabricator.haskell.org/D3072
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, GHC was extremely permissive about the form a default type
signature could take on in a class declaration. Notably, it would accept
garbage like this:
class Monad m => MonadSupply m where
fresh :: m Integer
default fresh :: MonadTrans t => t m Integer
fresh = lift fresh
And then give an extremely confusing error message when you actually
tried to declare an empty instance of MonadSupply. We now do extra
validity checking of default type signatures to ensure that they align
with their non-default type signature counterparts. That is, a default
type signature is allowed to differ from the non-default one only in its
context - they must otherwise be alpha-equivalent.
Fixes #12918.
Test Plan: ./validate
Reviewers: goldfire, simonpj, austin, bgamari
Reviewed By: bgamari
Subscribers: mpickering, dfeuer, thomie
Differential Revision: https://phabricator.haskell.org/D2983
GHC Trac Issues: #12918
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The `clean_cmd` and `extra_clean` setup functions don't do anything.
Remove them from .T files.
Created using https://github.com/thomie/refactor-ghc-testsuite. This
diff is a test for the .T-file parser/processor/pretty-printer in that
repository.
find . -name '*.T' -exec ~/refactor-ghc-testsuite/Main "{}" \;
Tests containing inline comments or multiline strings are not modified.
Preparation for #12223.
Test Plan: Harbormaster
Reviewers: austin, hvr, simonmar, mpickering, bgamari
Reviewed By: mpickering
Subscribers: mpickering
Differential Revision: https://phabricator.haskell.org/D3000
GHC Trac Issues: #12223
|
|
|
|
|
|
|
|
|
|
|
|
| |
Test Plan: validate
Reviewers: simonpj, austin, bgamari, goldfire
Reviewed By: bgamari, goldfire
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2829
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Add prettyprinter tests, which take a file, parse it, pretty print it,
re-parse the pretty printed version and then compare the original and
new ASTs (ignoring locations)
Updates haddock submodule to match the AST changes.
There are three issues outstanding
1. Extra parens around a context are not reproduced. This will require an
AST change and will be done in a separate patch.
2. Currently if an `HsTickPragma` is found, this is not pretty-printed,
to prevent noise in the output.
I am not sure what the desired behaviour in this case is, so have left
it as before. Test Ppr047 is marked as expected fail for this.
3. Apart from in a context, the ParsedSource AST keeps all the parens from
the original source. Something is happening in the renamer to remove the
parens around visible type application, causing T12530 to fail, as the
dumped splice decl is after the renamer.
This needs to be fixed by keeping the parens, but I do not know where they
are being removed. I have amended the test to pass, by removing the parens
in the expected output.
Test Plan: ./validate
Reviewers: goldfire, mpickering, simonpj, bgamari, austin
Reviewed By: simonpj, bgamari
Subscribers: simonpj, goldfire, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D2752
GHC Trac Issues: #3384
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch reverts the change introduced with
587dcccfdfa7a319e27300a4f3885071060b1f8e and restores the previous
default output of GHC (i.e., show source path and object path for each
compiled module).
The -fhide-source-paths flag can be used to hide these paths and reduce
the line
noise.
Reviewers: gracjan, nomeata, austin, bgamari, simonmar, hvr
Reviewed By: hvr
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2728
GHC Trac Issues: #12851
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: simonmar, mpickering, austin, bgamari
Reviewed By: bgamari
Subscribers: mpickering, nomeata, thomie
Differential Revision: https://phabricator.haskell.org/D2679
GHC Trac Issues: #12807
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
This implements the ability to derive associated type family instances
for newtypes automatically using `GeneralizedNewtypeDeriving`. Refer to the
users' guide additions for how this works; I essentially follow the pattern
laid out in https://ghc.haskell.org/trac/ghc/ticket/8165#comment:18.
Fixes #2721 and #8165.
Test Plan: ./validate
Reviewers: simonpj, goldfire, austin, bgamari
Reviewed By: simonpj
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D2636
GHC Trac Issues: #2721, #8165
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allows users to explicitly request which approach to `deriving` to use
via keywords, e.g.,
```
newtype Foo = Foo Bar
deriving Eq
deriving stock Ord
deriving newtype Show
```
Fixes #10598. Updates haddock submodule.
Test Plan: ./validate
Reviewers: hvr, kosmikus, goldfire, alanz, bgamari, simonpj, austin,
erikd, simonmar
Reviewed By: alanz, bgamari, simonpj
Subscribers: thomie, mpickering, oerjan
Differential Revision: https://phabricator.haskell.org/D2280
GHC Trac Issues: #10598
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In an instance declaration when you don't specify the code for a
method, GHC fills in from the default binding in the class.
The type of the default method can legitmiately be ambiguous ---
see Note [Default methods in instances] in TcInstDcls --- so
typechecking it can be tricky.
Trac #12220 showed that although we were dealing with that ambiguity
for /vanilla/ default methods, we were not doing so for /generic/
default methods. Moreover we were dealing with it clumsily, by
generating post-typechecked code.
This patch fixes the bug AND deletes code! We now use the same code
path for both vanilla and generic default methods; and generate
/pre-typechecked/ code in both cases. The key trick is that we can use
Visible Type Application to deal with the ambiguity, which wasn't
possible before. Hooray.
There is a small hit to performance in compiler/perf/T1969 which
consists of nothing BUT instance declarations with several default
methods to fill, which we now have to typecheck. The actual hit is
from 724 -> 756 or 4% in that extreme example. Real world programs
have vastly fewer instance decls.
|
|
|
|
| |
Fixes Trac #12163. Pretty simple.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, derived implementations of `to`/`from` in `Generic`
instances were wastefully putting extra `M1`s in every case, which led
to an O(n) increase in the number of coercions, resulting in a slowdown
during the typechecker phase.
This factors out the common `M1` in every case of a `to`/`from`
definition so that the typechecker has far fewer coercions to deal with.
For a datatype with 300 constructors, this change has been observed to
save almost 3 seconds of compilation time.
This is one step towards coming up with a solution for #5642.
Test Plan: ./validate
Reviewers: hvr, austin, simonpj, bgamari
Reviewed By: bgamari
Subscribers: basvandijk, carter, thomie, osa1
Differential Revision: https://phabricator.haskell.org/D2304
GHC Trac Issues: #5642
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This generalizes the `Generic1` typeclass to be of kind `k -> *`, and
this also makes the relevant datatypes and typeclasses in `GHC.Generics`
poly-kinded. If `PolyKinds` is enabled, `DeriveGeneric` derives
`Generic1` instances such that they use the most general kind possible.
Otherwise, deriving `Generic1` defaults to make an instance where the
argument is of kind `* -> *` (the current behavior).
Fixes #10604. Depends on D2117.
Test Plan: ./validate
Reviewers: kosmikus, dreixel, goldfire, austin, hvr, simonpj, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie, ekmett
Differential Revision: https://phabricator.haskell.org/D2168
GHC Trac Issues: #10604
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, deriving `Generic(1)` bailed out when attempting to
instantiate visible type parameters (#5939), but this instantiation
check was quite fragile and doesn't interact well with `-XTypeInType`.
It has been decided that `Generic(1)` shouldn't be subjected to this
check anyway, so it has been removed, and `gen_Generic_binds`'s
machinery has been updated to substitute the type variables in a
generated `Rep`/`Rep1` instance with the user-supplied type arguments.
In addition, this also refactors `Condition` in `TcDeriv` a bit. Namely,
since we no longer need `tc_args` to check any conditions, the `[Type]`
component of `Condition` has been removed.
Fixes #11732.
Test Plan: ./validate
Reviewers: goldfire, kosmikus, simonpj, bgamari, austin
Reviewed By: simonpj, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2061
GHC Trac Issues: #5939, #11732
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When optimizations are enabled, primitive string literals can be
inlined, which can create two copies of a string constant with different
addresses. We want to avoid this behavior at all costs in the `GEq1`
test, since the output depends on the result of `eqAddr#`. We prevent
such inlining through use of the `{-# NOINLINE #-}` pragma.
Fixes #11292.
Test Plan: Validate with T11292
Reviewers: thomie, austin, bgamari
Reviewed By: bgamari
Differential Revision: https://phabricator.haskell.org/D1714
GHC Trac Issues: #11292
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Test Plan: Validate.
Reviewers: simonpj, goldfire, hvr, dreixel, kosmikus, austin, bgamari
Reviewed By: kosmikus, austin, bgamari
Subscribers: RyanGlScott, Fuuzetsu, bgamari, thomie, carter, dreixel
Differential Revision: https://phabricator.haskell.org/D493
GHC Trac Issues: #9766
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Unlike `-XDefaultSignatures`, `-XDeriveAnyClass` would not fill in
associated type family defaults when deriving a class which contained
them.
In order to fix this properly, `tcATDefault` needed to be used from
`TcGenDeriv`. To avoid a module import cycle, `tcATDefault` was moved
from `TcInstDcls` to `TcClsDcl`.
Fixes #10361.
Test Plan: ./validate
Reviewers: kosmikus, dreixel, bgamari, austin, simonpj
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1283
GHC Trac Issues: #10361
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds a data family (`URec`) and six data family instances (`UAddr`,
`UChar`, `UDouble`, `UFloat`, `UInt`, and `UWord`) which a `deriving
Generic(1)` clause will generate if it sees `Addr#`, `Char#`, `Double#`,
`Float#`, `Int#`, or `Word#`, respectively. The programmer can then
provide instances for these data family instances to provide custom
implementations for unboxed types, similar to how derived `Eq`, `Ord`,
and `Show` instances currently special-case unboxed types.
Fixes #10868.
Test Plan: ./validate
Reviewers: goldfire, dreixel, bgamari, austin, hvr, kosmikus
Reviewed By: dreixel, kosmikus
Subscribers: simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D1239
GHC Trac Issues: #10868
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
DeriveGeneric generates some data types (for data type constructors and for
selectors of those constructors) and instances for those types. This patch
changes name generation for these new types to make it working with data types
with same names imported from different modules and with data types with same
names imported from same modules(using module imports).
Bonus content:
- Some refactoring in `TcGenGenerics.metaTyConsToDerivStuff` to remove some
redundant partial function applications and to remove a duplicated function.
- Remove some unused names from `OccName`. (those were used for an old
implementation of `DeriveGeneric`)
Reviewers: kosmikus, simonpj, dreixel, ezyang, bgamari, austin
Reviewed By: bgamari, austin
Subscribers: ezyang, thomie
Differential Revision: https://phabricator.haskell.org/D1081
GHC Trac Issues: #10487
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Change the error message generated when a deriving clause related to a newtype
fails to always suggested trying GeneralizedNewtypeDeriving, even in
situations where it may not work. Fixes #9600.
Test Plan: testsuite/deriving/should_fail/9600.hs
Reviewers: austin, bgamari, simonpj
Rebased-by: bgamari
Reviewed By: simonpj
Subscribers: bgamari, hvr, simonmar, carter
Differential Revision: https://phabricator.haskell.org/D216
GHC Trac Issues: #9600
|
|
|
|
|
| |
No point in pretending other compilers can use the GHC testsuite. This
makes the *.T files a bit shorter.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* extra_clean argument should be a list
Add an assert to prevent regressions.
* properly clean package conf direcories
They are directories now, which was causing problems.
* properly clean write_interface_* tests
We were getting these errors:
[Errno 21] Is a directory: './driver/write_interface_oneshot'
[Errno 39] Directory not empty: './driver/write_interface_oneshot'
[Errno 21] Is a directory: './driver/write_interface_make'
[Errno 39] Directory not empty: './driver/write_interface_make'
* outputdir() is better than -outputdir, as it knows how to (pre)clean
itself.
|
|
|
|
|
|
| |
Reviewed By: hvr, austin
Differential Revision: https://phabricator.haskell.org/D770
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Added packageName to GHC.Generics.Datatype class definition
Reviewers: hvr, dreixel, austin
Reviewed By: dreixel, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D631
GHC Trac Issues: #10030
|
|
|
|
|
|
|
| |
I found several tests that failed when the interface file format changed,
due to leftover .hi file droppings.
I'm not sure I've done this right, but it should be a bit better
|
|
|
|
|
|
| |
T5462Yes1/T5462Yes2/T5462No1 failure)
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: (this has been submitted on behalf on @dreixel)
Reviewers: simonpj, hvr, austin
Reviewed By: simonpj, austin
Subscribers: goldfire, thomie, carter, dreixel
Differential Revision: https://phabricator.haskell.org/D476
GHC Trac Issues: #5462
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Deprecate -XOverlappingInstances
* Update test suite. Several tests even had entirely unnecessary
uses of -XOverlappingInstances
* Update user manual with a careful description of the instance
resolution story
* Fix an outright bug in the handling of duplidate instances in GHCi,
which are meant to silently overwrite the earlier duplicate. The
logic was right for family instances but was both more complicated,
and plain wrong, for class instances. (If you are interested, the
bug was that we were eliminating the duplicate from the InstEnv, but
not from the [ClsInst] held in tcg_insts.) Test is ghci044a.
|
|
|
|
|
|
|
|
| |
When deriving Functor, Foldable, Traversable, we need only look at the
way that the last type argument is treated. It's fine for there to
be existentials etc, provided they don't affect the last type argument.
See Note [Check that the type variable is truly universal] in TcDeriv.
|
|
|
|
|
|
|
| |
This matches GCC's choice of Unicode quotation marks (i.e. U+2018 and U+2019)
and therefore looks more familiar on the console. This addresses #2507.
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
|
| |
|
| |
|
|
|
|
| |
(this is related to #3647)
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|