summaryrefslogtreecommitdiff
path: root/compiler/prelude/PrelRules.lhs
Commit message (Collapse)AuthorAgeFilesLines
* compiler: de-lhs prelude/Austin Seipp2014-12-031-1330/+0
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* use correct word size for shiftRightLogical and removeOp32Luite Stegeman2014-11-191-16/+26
| | | | | | | | | | | | | | | | | | | | | | Summary: shiftRightLogical used a host sized Word for the intermediate value, which would produce the wrong result when cross compiling to a target with a different word size than the host. removeOp32 used the preprocessor to bake in word size assumptions, rather than getting the target word size from DynFlags Test Plan: validate Reviewers: hvr, rwbarton, carter, austin Reviewed By: austin Subscribers: thomie, carter Differential Revision: https://phabricator.haskell.org/D502 GHC Trac Issues: #9736
* Don't re-export `Alternative(..)` from Control.Monad (re #9586)Herbert Valerio Riedel2014-09-261-1/+3
| | | | | | | | | | | | | | | | | 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
* Make Applicative a superclass of MonadAustin Seipp2014-09-091-0/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-2/+2
| | | | | | | | | | | | | | | | | | 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.
* Add BuiltinRules for constant-folding not# and notI# (logical complement)Simon Peyton Jones2014-03-131-0/+9
| | | | | | | | I don't know why these constant-folding rules were implemented for and/or/xor but not for 'not'. Adding them is part of the fix for Trac #8832. (The other part is in Data.Bits.)
* Guarding against silly shiftsSimon Peyton Jones2013-12-121-12/+68
| | | | | This patch was authored by SPJ and extracted from "Improve the handling of used-once stuff" by Joachim.
* Update and clean-up the implmenation of GHC.TypeLitsIavor S. Diatchki2013-10-091-15/+15
| | | | | | | | | | | | | | | | | | * Replace class `SingI` with two separate classes: `KnownNat` and `KnownSymbol` * Rename `magicSingId` to `magicDictId`. * Simplify and clean-up the "magic" implementation. This version makes a lot more sense, at least to me :-) * Update notes about how it all works: Note [KnownNat & KnownSymbol and EvLit] explains the evidence for the built-in classes Note [magicDictId magic] explains how we coerce singleton values into dictionaries. This is used to turn run-time integers and strings into Proxy singletons of unknwon type (using an existential).
* Fix AMP warnings.Austin Seipp2013-09-111-0/+12
| | | | | Authored-by: David Luposchainsky <dluposchainsky@gmail.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Comments onlyJan Stolarek2013-08-191-0/+1
| | | | Documentation of Integer constant folding
* Comparison primops return Int# (Fixes #6135)Jan Stolarek2013-08-141-63/+101
| | | | | | | | | | | | This patch modifies all comparison primops for Char#, Int#, Word#, Double#, Float# and Addr# to return Int# instead of Bool. A value of 1# represents True and 0# represents False. For a more detailed description of motivation for this change, discussion of implementation details and benchmarking results please visit the wiki page: http://hackage.haskell.org/trac/ghc/wiki/PrimBool There's also some cleanup: whitespace fixes in files that were extensively edited in this patch and constant folding rules for Integer div and mod operators (which for some reason have been left out up till now).
* Comments onlyJan Stolarek2013-08-121-6/+6
|
* Implement "roles" into GHC.Richard Eisenberg2013-08-021-2/+2
| | | | | | | | | | | | | | | | Roles are a solution to the GeneralizedNewtypeDeriving type-safety problem. Roles were first described in the "Generative type abstraction" paper, by Stephanie Weirich, Dimitrios Vytiniotis, Simon PJ, and Steve Zdancewic. The implementation is a little different than that paper. For a quick primer, check out Note [Roles] in Coercion. Also see http://ghc.haskell.org/trac/ghc/wiki/Roles and http://ghc.haskell.org/trac/ghc/wiki/RolesImplementation For a more formal treatment, check out docs/core-spec/core-spec.pdf. This fixes Trac #1496, #4846, #7148.
* Add strength reduction rules (Fixes #7116)Jan Stolarek2013-07-311-6/+27
| | | | | This patch adds rules for converting floating point multiplication of the form 2.0 * x and x * 2.0 into addition x + x.
* Fix many ASSERT uses under Clang.Austin Seipp2013-06-181-1/+1
| | | | | | Clang doesn't like whitespace between macro and arguments. Signed-off-by: Austin Seipp <aseipp@pobox.com>
* Use the symmetric version of the newtype coercion.Iavor S. Diatchki2013-05-311-6/+6
|
* Add a primitive for coercing values into dictionaries in a special case.Iavor S. Diatchki2013-05-301-3/+22
| | | | The details of this are described in Note [magicSingIId magic] in basicTypes/MkId.lhs
* Make 'SPECIALISE instance' work againSimon Peyton Jones2013-05-301-128/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a long-standing regression (Trac #7797), which meant that in particular the Eq [Char] instance does not get specialised. (The *methods* do, but the dictionary itself doesn't.) So when you call a function f :: Eq a => blah on a string type (ie a=[Char]), 7.6 passes a dictionary of un-specialised methods. This only matters when calling an overloaded function from a specialised context, but that does matter in some programs. I remember (though I cannot find the details) that Nick Frisby discovered this to be the source of some pretty solid performanc regresisons. Anyway it works now. The key change is that a DFunUnfolding now takes a form that is both simpler than before (the DFunArg type is eliminated) and more general: data Unfolding = ... | DFunUnfolding { -- The Unfolding of a DFunId -- See Note [DFun unfoldings] -- df = /\a1..am. \d1..dn. MkD t1 .. tk -- (op1 a1..am d1..dn) -- (op2 a1..am d1..dn) df_bndrs :: [Var], -- The bound variables [a1..m],[d1..dn] df_con :: DataCon, -- The dictionary data constructor (never a newtype datacon) df_args :: [CoreExpr] -- Args of the data con: types, superclasses and methods, } -- in positional order That in turn allowed me to re-enable the DFunUnfolding specialisation in DsBinds. Lots of details here in TcInstDcls: Note [SPECIALISE instance pragmas] I also did some refactoring, in particular to pass the InScopeSet to exprIsConApp_maybe (which in turn means it has to go to a RuleFun). NB: Interface file format has changed!
* Primitive bitwise operations on Int# (Fixes #7689)Jan Stolarek2013-02-181-0/+9
|
* Introduce CPR for sum types (Trac #5075)Simon Peyton Jones2013-01-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main payload of this patch is to extend CPR so that it detects when a function always returns a result constructed with the *same* constructor, even if the constructor comes from a sum type. This doesn't matter very often, but it does improve some things (results below). Binary sizes increase a little bit, I think because there are more wrappers. This with -split-objs. Without split-ojbs binary sizes increased by 6% even for HelloWorld.hs. It's hard to see exactly why, but I think it was because System.Posix.Types.o got included in the linked binary, whereas it didn't before. Program Size Allocs Runtime Elapsed TotalMem fluid +1.8% -0.3% 0.01 0.01 +0.0% tak +2.2% -0.2% 0.02 0.02 +0.0% ansi +1.7% -0.3% 0.00 0.00 +0.0% cacheprof +1.6% -0.3% +0.6% +0.5% +1.4% parstof +1.4% -4.4% 0.00 0.00 +0.0% reptile +2.0% +0.3% 0.02 0.02 +0.0% ---------------------------------------------------------------------- Min +1.1% -4.4% -4.7% -4.7% -15.0% Max +2.3% +0.3% +8.3% +9.4% +50.0% Geometric Mean +1.9% -0.1% +0.6% +0.7% +0.3% Other things in this commit ~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Got rid of the Lattice class in Demand * Refactored the way that products and newtypes are decomposed (no change in functionality)
* Fix some incorrect narrowing rules (#7361)Simon Marlow2013-01-091-12/+12
| | | | e.g. narrow8Int# subsumes narrow16Int#, not the other way around.
* Inline some FastBytes/ByteString wrappersIan Lynagh2012-12-141-1/+2
| | | | Working towards removing FastBytes
* Merge branch 'master' of http://darcs.haskell.org/ghcSimon Peyton Jones2012-10-241-0/+30
|\
| * Use fromRational when pre-computing fromRational literalsIan Lynagh2012-10-211-1/+2
| | | | | | | | | | This makes it easier to be confident that the optimisation gives the right answer.
| * add GHC.Float.rationalToFloat, rationalToDouble (fixes #7295)John Lato2012-10-211-0/+29
| | | | | | | | | | | | Adds better support for constant folding of Float/Double literals. - add rationalToFloat, rationalToDouble with associated Name/Id's in PrelNames. - add a matching rule in PrelRules for rationalTo* functions.
* | Merge branch 'master' of http://darcs.haskell.org/ghcSimon Peyton Jones2012-10-221-11/+54
|\ \ | |/
| * Add a rule for (plusAddr# x 0) == x; fixes #7284Ian Lynagh2012-10-211-0/+2
| |
| * Add some more PrimOp rulesIan Lynagh2012-10-211-0/+7
| |
| * Add some more primop rules; fixes #7286Ian Lynagh2012-10-211-11/+45
| | | | | | | | | | As well as the rules mentioned in the ticket, I've also gone through and added some more rules that might be useful in other cases.
* | Merge branch 'master' of http://darcs.haskell.org/ghcSimon Peyton Jones2012-10-191-2/+2
|\ \ | |/
| * Some alpha renamingIan Lynagh2012-10-161-2/+2
| | | | | | | | | | Mostly d -> g (matching DynFlag -> GeneralFlag). Also renamed if* to when*, matching the Haskell if/when names
* | Deprecate Rank2Types and PolymorphicComponents, in favour of RankNTypesSimon Peyton Jones2012-10-191-1/+1
|/ | | | | We agreed that it's not worth the bother of trying to maintain all these distinct flags; RankNTypes will do the job fine. Trac #6032.
* Make -fexcess-precision a fully-dynamic flagIan Lynagh2012-10-091-17/+16
| | | | It used to be part-dynamic, part-static.
* Make some uses of minBound/maxBound use the target Int/Word sizesIan Lynagh2012-09-191-27/+28
|
* Remove the Target* types from HaskellConstantsIan Lynagh2012-09-171-7/+13
|
* Move tARGET_* out of HaskellConstantsIan Lynagh2012-09-171-105/+140
|
* Pass DynFlags to the ru_try functions of built-in rulesIan Lynagh2012-09-171-41/+58
|
* Fix warning on x86-64Paolo Capriotti2012-07-271-6/+3
|
* Migrate more rules to PrelRules.Paolo Capriotti2012-07-261-9/+37
| | | | | | | | | | Move the following primop rules from GHC.Base to PrelRules: "narrow32Int#" forall x#. narrow32Int# x# = x# "narrow32Word#" forall x#. narrow32Word# x# = x# "int2Word2Int" forall x#. int2Word# (word2Int# x#) = x# "word2Int2Word" forall x#. word2Int# (int2Word# x#) = x#
* Refactor prel rules: always return a single rule.Paolo Capriotti2012-07-241-84/+72
|
* Refactor PrelRules and add more rules (#7014)Paolo Capriotti2012-07-241-246/+334
| | | | | Ported various rules for numeric types from GHC.Base. Added new rules for bitwise operations, shifts and word comparisons.
* Add some more Integer rulesIan Lynagh2012-07-181-10/+14
|
* Implement FastBytes, and use it for MachStrIan Lynagh2012-07-141-1/+1
| | | | | | | | | | | | | This is a first step on the way to refactoring the FastString type. FastBytes currently has no unique, mainly because there isn't currently a nice way to produce them in Binary. Also, we don't currently do the "Dictionary" thing with FastBytes in Binary. I'm not sure whether this is important. We can change both decisions later, but in the meantime this gets the refactoring underway.
* Comments onlySimon Peyton Jones2012-07-141-0/+5
|
* Add some more Integer rules; fixes #6111Ian Lynagh2012-06-271-1/+36
|
* Fix Word64ToInteger conversion rule.Paolo Capriotti2012-06-251-1/+1
|
* Add some more Integer rulesIan Lynagh2012-06-081-3/+57
|
* Add rules for intToInteger and wordToIntegerIan Lynagh2012-06-061-2/+35
|
* Put the Integer type, rather than the mkIntegerId, inside LitIntegerIan Lynagh2012-06-061-10/+6
| | | | | This will make it possible to write PrelRules that produce an Integer result without having Integer arguments.
* Tell built-in rules the Id that the rule has matchedIan Lynagh2012-06-061-27/+36
| | | | | | | | This will let us get at the types of the Id, which in particular means that for a rule for intToInteger :: Int# -> Integer we can get the "Integer" type, which we can use to build an Integer literal.