summaryrefslogtreecommitdiff
path: root/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
* Update Foreign.* for Safe Haskell now that they're safe by defaultDavid Terei2014-11-212-0/+8
|
* AST changes to prepare for API annotations, for #9628Alan Zimmerman2014-11-211-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: AST changes to prepare for API annotations Add locations to parts of the AST so that API annotations can then be added. The outline of the whole process is captured here https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations This change updates the haddock submodule. Test Plan: sh ./validate Reviewers: austin, simonpj, Mikolaj Reviewed By: simonpj, Mikolaj Subscribers: thomie, goldfire, carter Differential Revision: https://phabricator.haskell.org/D426 GHC Trac Issues: #9628
* arm64: 64bit iOS and SMP support (#7942)Luke Iannini2014-11-191-0/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Refactor: use System.FilePath.splitSearchPathThomas Miedema2014-11-191-21/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To address #2521 ("Trailing colon on GHC_PACKAGE_PATH doesn't work with ghc-pkg"), we were using a custom version of splitSearchPath (e4f46f5de). This solution however caused issue #9698 ("GHC_PACKAGE_PATH should be more lenient for empty paths"). This patch reverts back to System.FilePath.splitSearchPath (fixes #9698) and adresses (#2521) by testing for a trailing search path separators explicitly (instead of implicitly using empty search path elements). Empty paths are now allowed (ignored on Windows, interpreted as current directory on Posix systems), and trailing path separator still tack on the user and system package databases. Also update submodule filepath, which has a version of splitSearchPath which handles quotes in the same way as our custom version did. Test Plan: $ GHC_PACKAGE_PATH=/::/home: ./ghc-pkg list ... db stack: ["/",".","/home","<userdb>","<systemdb>"] ... Reviewers: austin Reviewed By: austin Subscribers: thomie, carter, simonmar Differential Revision: https://phabricator.haskell.org/D414 GHC Trac Issues: #2521, #9698
* Fix #9404 by removing tcInfExpr.Richard Eisenberg2014-11-121-0/+6
| | | | | | See the ticket for more info about the new algorithm. This is a small simplification, unifying the treatment of type checking in a few similar situations.
* Remove redundant contexts from Foldable methodsDavid Feuer2014-11-051-17/+3
| | | | | | | | | | | New `Foldable` methods accidentally had `Foldable` contexts, which led to type roles being assigned incorrectly and preventing GND from deriving `Foldable` instances. Removing those fixes #9761. Moreover, this patch takes advantage of this fix by deriving `Foldable` (and `Eq`) for `UniqFM`. Differential Revision: https://phabricator.haskell.org/D425
* Some refactoring around endPass and debug dumpingSimon Peyton Jones2014-11-041-35/+46
| | | | | I forget all the details, but I spent some time trying to understand the current setup, and tried to simplify it a bit
* Use Data.Map.mergeWithKeyJoachim Breitner2014-10-081-7/+0
| | | | | | | | | | Summary: now that we can rely on having containers > 0.5. Reviewers: austin Subscribers: thomie, carter, ezyang, simonmar Differential Revision: https://phabricator.haskell.org/D321
* Use dropWhileEndLE p instead of reverse . dropWhile p . reverseDavid Feuer2014-10-021-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Using `dropWhileEndLE` tends to be faster and easier to read than the `reverse . dropWhile p . reverse` idiom. This also cleans up some other, nearby, messes. Fix #9616 (incorrect number formatting potentially leading to incorrect numbers in output). Test Plan: Run validate Reviewers: thomie, rwbarton, nomeata, austin Reviewed By: nomeata, austin Subscribers: simonmar, ezyang, carter, thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D259 GHC Trac Issues: #9623, #9616 Conflicts: compiler/basicTypes/OccName.lhs
* Revert "Use dropWhileEndLE p instead of reverse . dropWhile p . reverse"Austin Seipp2014-10-021-15/+1
| | | | This reverts commit 2a8856884de7d476e26b4ffa829ccb3a14d6f63e.
* Use dropWhileEndLE p instead of reverse . dropWhile p . reverseDavid Feuer2014-10-011-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Using `dropWhileEndLE` tends to be faster and easier to read than the `reverse . dropWhile p . reverse` idiom. This also cleans up some other, nearby, messes. Fix #9616 (incorrect number formatting potentially leading to incorrect numbers in output). Test Plan: Run validate Reviewers: thomie, rwbarton, nomeata, austin Reviewed By: nomeata, austin Subscribers: simonmar, ezyang, carter, thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D259 GHC Trac Issues: #9623, #9616 Conflicts: compiler/basicTypes/OccName.lhs
* [ci skip] Kill tabs in md5.hAustin Seipp2014-10-011-3/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Don't re-export `Alternative(..)` from Control.Monad (re #9586)Herbert Valerio Riedel2014-09-261-2/+0
| | | | | | | | | | | | | | | | | This was done in d94de87252d0fe2ae97341d186b03a2fbe136b04 to avoid orphans but since a94dc4c3067c6a0925e2e39f35ef0930771535f1 moved `Alternative` into GHC.Base, this isn't needed anymore. This is important, as otherwise this would require a non-neglectable amount of `Control.Monad hiding ((<|>), empty)` imports in user code. The Haddock submodule is updated as well Test Plan: partial local ./validate --fast, let Harbormaster doublecheck it Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D248
* Delete hack that was once needed to fix the buildThomas Miedema2014-09-251-3/+5
| | | | | | | | | | | | | | | | | Summary: Introduced in 6c7b41cc2b24f533697a62bf1843507ae043fc97. I checked the rest of that commit, and this is all that was left to revert. Test Plan: x Reviewers: ezyang, austin Reviewed By: ezyang, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D241
* Delete all /* ! __GLASGOW_HASKELL__ */ codeThomas Miedema2014-09-238-181/+0
| | | | | | | | | | | | | | | | | Summary: ``` git grep -l '\(#ifdef \|#if defined\)(\?__GLASGOW_HASKELL__)\?' ``` Test Plan: validate Reviewers: rwbarton, hvr, austin Reviewed By: rwbarton, hvr, austin Subscribers: rwbarton, simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D218
* Delete hack when takeDirectory returns ""Thomas Miedema2014-09-231-5/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: Since commits 8fe1f8 and bb6731 in the filepath packages (ticket #2034, closed in 2010), takeDirectory "foo" returns ".", and not "", so this check is no longer needed. Other commits: * Remove trailing whitespace * Update comments for #2278 Test Plan: harbormaster Reviewers: austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D213 GHC Trac Issues: #2034
* Export `Monoid(..)`/`Foldable(..)`/`Traversable(..)` from PreludeHerbert Valerio Riedel2014-09-212-3/+10
| | | | | | | | | | | | | | | This finally exposes also the methods of these 3 classes in the Prelude in order to allow to define basic class instances w/o needing imports. This almost completes the primary goal of #9586 NOTE: `fold`, `foldl'`, `foldr'`, and `toList` are not exposed yet, as they require upstream fixes for at least `containers` and `bytestring`, and are not required for defining basic instances. Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D236
* Define Util.leLength :: [a] -> [b] -> BoolSimon Peyton Jones2014-09-191-1/+9
|
* Return nBytes instead of nextAddr from utf8DecodeCharThomas Miedema2014-09-163-28/+29
| | | | | | | | | | | | | | | | | | | | | Summary: While researching D176, I came across the following simplification opportunity: Not all functions that call utf8DecodeChar actually need the address of the next char. And some need the 'number of bytes' read. So returning nBytes instead of nextAddr should save a few addition and subtraction operations, and makes the code a bit simpler. Test Plan: it validates Reviewers: simonmar, ezyang, austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D179
* Export `Traversable()` and `Foldable()` from PreludeHerbert Valerio Riedel2014-09-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | This exposes *only* the type-classes w/o any of their methods. This is the very first step for implementing BPP (see #9586), which already requires breaking up several import-cycles leading back to `Prelude`. Ideally, importing `Prelude` should be avoided in most `base` modules, as `Prelude` does not define any entities, but rather re-exports existing ones. Test Plan: validate passes Reviewers: ekmett, austin Reviewed By: ekmett, austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D209 GHC Trac Issues: #9586
* Make Applicative a superclass of MonadAustin Seipp2014-09-093-1/+10
| | | | | | | | | | | | | | | | | | | | | Summary: This includes pretty much all the changes needed to make `Applicative` a superclass of `Monad` finally. There's mostly reshuffling in the interests of avoid orphans and boot files, but luckily we can resolve all of them, pretty much. The only catch was that Alternative/MonadPlus also had to go into Prelude to avoid this. As a result, we must update the hsc2hs and haddock submodules. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: Build things, they might not explode horribly. Reviewers: hvr, simonmar Subscribers: simonmar Differential Revision: https://phabricator.haskell.org/D13
* StringBuffer should not contain initial byte-order mark (BOM)Thomas Miedema2014-09-011-13/+32
| | | | | | | | | | | | | | | | | | | | Summary: Just skipping over a BOM, but leaving it in the Stringbuffer, is not sufficient. The Lexer calls prevChar when a regular expression starts with '^' (which is a shorthand for '\n^'). It would never match on the first line, since instead of '\n', prevChar would still return '\xfeff'. Test Plan: validate Reviewers: austin, ezyang Reviewed By: austin, ezyang Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D176 GHC Trac Issues: #6016
* Make mkFastStringByteString pure and fix up usesDuncan Coutts2014-08-292-8/+9
| | | | It's morally pure, and we'll need it in a pure context.
* Use DumpStyle rather than UserStyle for pprTrace outputSimon Peyton Jones2014-08-251-2/+2
| | | | | | | | The main motivation is that user-style output assumes that everything has been tidied, not enough uniques are printed by default. The downside is that pprTrace output now has module prefixes which can be overwhelming, but -dsuppress-module-prefixes will suppress them.
* utils: detabify/dewhitespace GraphPprAustin Seipp2014-08-201-136/+128
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* utils: detabify/dewhitespace GraphBaseAustin Seipp2014-08-201-72/+59
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* utils: detabify/dewhitespace BufWriteAustin Seipp2014-08-201-42/+35
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* build: require GHC 7.6 for bootstrappingAustin Seipp2014-08-192-30/+0
| | | | | | | | | | | | | | | | | | | | | | Summary: Per the usual standards, a build of GHC is only compileable by the last two releases (e.g. 7.8 only by 7.4 and 7.6). To make sure we don't get suckered into supporting older compilers, let's remove this support now. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: Try to bootstrap with GHC 7.4, watch it fail. Bootstrap with 7.6 or better, and everything works. Reviewers: hvr Reviewed By: hvr Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D167
* Give the Unique generated by strings a tag '$', fixes #9413.Edward Z. Yang2014-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | Summary: Previously, we allocated uniques for strings starting at zero, which means the tag bits in the unique are zero, which means that printing a Unique for a string will start with a null byte. This is bad. So instead, start our numbering with the tag byte as '$' (as in $tring). This is hard coded so we don't have to worry about the optimizer reducing the expression. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: hvr, simonmar, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D123 GHC Trac Issues: #9413
* Add Output instance for OrdListSimon Peyton Jones2014-08-071-0/+4
|
* Package keys (for linking/type equality) separated from package IDs.Edward Z. Yang2014-08-051-13/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch set makes us no longer assume that a package key is a human readable string, leaving Cabal free to "do whatever it wants" to allocate keys; we'll look up the PackageId in the database to display to the user. This also means we have a new level of qualifier decisions to make at the package level, and rewriting some Safe Haskell error reporting code to DTRT. Additionally, we adjust the build system to use a new ghc-cabal output Make variable PACKAGE_KEY to determine library names and other things, rather than concatenating PACKAGE/VERSION as before. Adds a new `-this-package-key` flag to subsume the old, erroneously named `-package-name` flag, and `-package-key` to select packages by package key. RFC: The md5 hashes are pretty tough on the eye, as far as the file system is concerned :( ToDo: safePkg01 test had its output updated, but the fix is not really right: the rest of the dependencies are truncated due to the fact the we're only grepping a single line, but ghc-pkg is wrapping its output. ToDo: In a later commit, update all submodules to stop using -package-name and use -this-package-key. For now, we don't do it to avoid submodule explosion. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D80
* Implement OVERLAPPING and OVERLAPPABLE pragmas (see #9242)Iavor S. Diatchki2014-07-271-4/+8
| | | | | | | | | | | | | | | | | | | | | | This also removes the short-lived NO_OVERLAP pragama, and renames OVERLAP to OVERLAPS. An instance may be annotated with one of 4 pragams, to control its interaction with other overlapping instances: * OVERLAPPABLE: this instance is ignored if a more specific candidate exists * OVERLAPPING: this instance is preferred over more general candidates * OVERLAPS: both OVERLAPPING and OVERLAPPABLE (i.e., the previous GHC behavior). When compiling with -XOverlappingInstances, all instance are OVERLAPS. * INCOHERENT: same as before (see manual for details). When compiling with -XIncoherentInstances, all instances are INCOHERENT.
* utils: detabify/dewhitespace DigraphAustin Seipp2014-07-201-43/+36
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix ghci tab completion of duplicate identifiers.Shachaf Ben-Kiki2014-07-131-1/+5
| | | | | | | | | | | | | | | | | | | Summary: Currently, if the same identifier is imported via multiple modules, ghci shows multiple completions for it. Use the nub of the completions instead so that it only shows up once. Signed-off-by: Shachaf Ben-Kiki <shachaf@gmail.com> Test Plan: by hand Reviewers: simonmar, austin, hvr Reviewed By: austin, hvr Subscribers: hvr, simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D58
* Factor-out the `OverlapMode` from `OverlapFlag`.Iavor S. Diatchki2014-06-291-9/+17
| | | | | | | | This seems a bit cleaner conceptually because the overlap mode and running in safety mode are quite orthogonal. More pragmatically, it also makes it possible to use `OverlapMode` to let programmers pick the overlap mode for individual instances.
* Better debug printingSimon Peyton Jones2014-06-121-2/+9
|
* Fix discarding of unreachable code in the register allocator (#9155)Simon Marlow2014-06-061-20/+12
| | | | | | | A previous fix to this was wrong: f5879acd018494b84233f26fba828ce376d0f81d and left some unreachable code behind. So rather than try to be clever and do this at the same time as the strongly-connected-component analysis, I'm doing a separate reachability pass first.
* Only use UnicodeSytanx pretty printing if the locale supports itJoachim Breitner2014-06-061-4/+5
| | | | using the same check as for unicode quotes.
* Use UnicodeSyntax when printingJoachim Breitner2014-06-061-9/+24
| | | | | When printing Haskell source, and UnicodeSyntax is enabled, use the unicode sytax characters (#8959).
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-1524-17/+35
| | | | | | | | | | | | | | | | | | In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been reorganized, while following the convention, to - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before any `{-# OPTIONS_GHC #-}`-lines. - Moreover, if the list of language extensions fit into a single `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each individual language extension. In both cases, try to keep the enumeration alphabetically ordered. (The latter layout is preferable as it's more diff-friendly) While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
* Avoid trivial cases of NondecreasingIndentationHerbert Valerio Riedel2014-05-151-4/+3
| | | | | | | This cleanup allows the following refactoring commit to avoid adding a few `{-# LANGUAGE NondecreasingIndentation #-}` pragmas. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Be less verbose when printing Names when we don't know what's in scopeSimon Peyton Jones2014-04-241-13/+12
| | | | | | | | Previously we always printed qualified names, but that makes a lot of debug or warning output very verbose. So now we only print qualified names with -dppr-debug. Civilised output (from pukka error messages, with the environment available) is unaffected
* ghc: initial AArch64 patchesColin Watson2014-04-211-0/+1
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Major Call Arity reworkJoachim Breitner2014-03-052-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the call arity analysis in various ways. Most importantly, it enriches the analysis result information so that when looking at a call, we do not have to make a random choice about what side we want to take the information from. Instead we can combine the results in a way that does not lose valuable information. To do so, besides the incoming arities, we store remember "what can be called with what", i.e. an undirected graph between the (interesting) free variables of an expression. Of course it makes combining the results a bit more tricky (especially mutual recursion), but still doable. The actually implemation of the graph structure is abstractly put away in a module of its own (UnVarGraph.hs) The implementation is geared towards efficiently representing the graphs that we need (which can contain large complete and large complete bipartite graphs, which would be huge in other representations). If someone feels like designing data structures: There is surely some speed-up to be obtained by improving that data structure. Additionally, the analysis now takes into account that if a RHS stays a thunk, then its calls happen only once, even if the variables the RHS is bound to is evaluated multiple times, or is part of a recursive group.
* Use U+2018 instead of U+201B quote mark in compiler messagesHerbert Valerio Riedel2014-02-251-1/+1
| | | | | | | 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>
* Fix Haddock formattingMateusz Kowalczyk2014-02-241-11/+13
|
* Cleaned up Maybes.lhsBaldur Blöndal2014-02-131-34/+4
|
* Fix inplace dynamic linking on OS X (#8266)Christiaan Baaj2014-01-281-0/+6
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Implement pattern synonymsDr. ERDI Gergo2014-01-202-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements Pattern Synonyms (enabled by -XPatternSynonyms), allowing y ou to assign names to a pattern and abstract over it. The rundown is this: * Named patterns are introduced by the new 'pattern' keyword, and can be either *unidirectional* or *bidirectional*. A unidirectional pattern is, in the simplest sense, simply an 'alias' for a pattern, where the LHS may mention variables to occur in the RHS. A bidirectional pattern synonym occurs when a pattern may also be used in expression context. * Unidirectional patterns are declared like thus: pattern P x <- x:_ The synonym 'P' may only occur in a pattern context: foo :: [Int] -> Maybe Int foo (P x) = Just x foo _ = Nothing * Bidirectional patterns are declared like thus: pattern P x y = [x, y] Here, P may not only occur as a pattern, but also as an expression when given values for 'x' and 'y', i.e. bar :: Int -> [Int] bar x = P x 10 * Patterns can't yet have their own type signatures; signatures are inferred. * Pattern synonyms may not be recursive, c.f. type synonyms. * Pattern synonyms are also exported/imported using the 'pattern' keyword in an import/export decl, i.e. module Foo (pattern Bar) where ... Note that pattern synonyms share the namespace of constructors, so this disambiguation is required as a there may also be a 'Bar' type in scope as well as the 'Bar' pattern. * The semantics of a pattern synonym differ slightly from a typical pattern: when using a synonym, the pattern itself is matched, followed by all the arguments. This means that the strictness differs slightly: pattern P x y <- [x, y] f (P True True) = True f _ = False g [True, True] = True g _ = False In the example, while `g (False:undefined)` evaluates to False, `f (False:undefined)` results in undefined as both `x` and `y` arguments are matched to `True`. For more information, see the wiki: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/Implementation Reviewed-by: Simon Peyton Jones <simonpj@microsoft.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Tidy up Outputable.printDoc, and add printDoc_Simon Peyton Jones2014-01-171-4/+11
| | | | | | The former adds a newline at the end (restoring the previous behaviour) while the latter does not (which previously happened by turning the thuing into a string and only then printing it).