summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Num.hs
Commit message (Collapse)AuthorAgeFilesLines
* Bignum: add Natural constant folding rules (#15821)Sylvain Henry2021-01-231-6/+6
| | | | | | | | | | | | | | | | | | | * Implement constant folding rules for Natural (similar to Integer ones) * Add mkCoreUbxSum helper in GHC.Core.Make * Remove naturalTo/FromInt We now only provide `naturalTo/FromWord` as the semantics is clear (truncate/zero-extend). For Int we have to deal with negative numbers (throw an exception? convert to Word beforehand?) so we leave the decision about what to do to the caller. Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#, etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#` (for example). * Replaced a few `()` with `(# #)`
* Bignum: fix for Integer/Natural Ord instancesSylvain Henry2021-01-171-14/+3
| | | | | | | | | * allow `integerCompare` to inline into `integerLe#`, etc. * use `naturalSubThrow` to implement Natural's `(-)` * use `naturalNegate` to implement Natural's `negate` * implement and use `integerToNaturalThrow` to implement Natural's `fromInteger` Thanks to @christiaanb for reporting these
* Update `base` packageSylvain Henry2020-06-171-20/+45
| | | | | | | | | | | | | | | * GHC.Natural isn't implemented in `base` anymore. It is provided by ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural primitives in `base` without fearing issues with built-in rewrite rules (cf #15286) * `base` doesn't conditionally depend on an integer-* package anymore, it depends on ghc-bignum * Some duplicated code in integer-* can now be factored in GHC.Float * ghc-bignum tries to use a uniform naming convention so most of the other changes are renaming
* Remove from `base` obsolete CPP for `integer-gmp`Alec Theriault2019-01-161-26/+0
| | | | | | | | | | * `GHC.Natural` now exports the same functions (regardless of integer backend) * remove unnecessary CPP around instances * remove the 'OPTIMISE_INTEGER_GCD_LCM' flag - almost all of those optimizations now work regardless of which integer backend is used Note that some CPP still remains for situations where there are backend-specific optimization hacks (like a more efficient GMP-only `gcd` for `Int#` and `Word#`).
* Remove OPTIONS_HADDOCK hide in favour for not-homeAdam Sandberg Eriksson2019-01-061-1/+1
| | | | GHC Trac Issues: #15447
* base: Misc haddock fixesSimon Jakobi2018-11-021-7/+7
| | | | (cherry picked from commit ee545ff44e0ba9a165de40807548c75bf181dda3)
* Fix ambiguous/out-of-scope Haddock identifiersAlec Theriault2018-08-211-2/+2
| | | | | | | | | | | | | | | | | This drastically cuts down on the number of Haddock warnings when making docs for `base`. Plus this means more actual links end up in the docs! Also fixed other small mostly markup issues in the documentation along the way. This is a docs-only change. Reviewers: hvr, bgamari, thomie Reviewed By: thomie Subscribers: thomie, rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5055
* Improve documentation of Eq, Ord instances for Float and DoubleARJANEN Loïc Jean David2018-06-171-2/+25
| | | | | | | | | | | | Reviewers: sjakobi, dfeuer, bgamari, hvr Reviewed By: sjakobi, bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15078 Differential Revision: https://phabricator.haskell.org/D4736
* Built-in Natural literals in CoreSylvain Henry2018-06-151-2/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for built-in Natural literals in Core. - Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber constructor with a LitNumType field - Support built-in Natural literals - Add desugar warning for negative literals - Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency reasons This patch introduces only a few rules for Natural literals (compared to Integer's rules). Factorization of the built-in rules for numeric literals will be done in another patch as this one is already big to review. Test Plan: validate test build with integer-simple Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar Reviewed By: bgamari Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton, thomie GHC Trac Issues: #14170, #14465 Differential Revision: https://phabricator.haskell.org/D4212
* Add @since annotations to base instancesSeraphime Kirkovski2016-06-061-0/+3
| | | | | | | | | | | | | | | | | | Add @since annotations to instances in `base`. Test Plan: * ./validate # some commets shouldn't break the build * review the annotations for absurdities. Reviewers: ekmett, goldfire, RyanGlScott, austin, hvr, bgamari Reviewed By: RyanGlScott, hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2277 GHC Trac Issues: #11767
* Revert "Add export lists to some modules."Austin Seipp2015-01-191-6/+1
| | | | | | This reverts commit d6e7f5dc9db7e382ce34d649f85505176a451a04. This commit broke the build on Windows due to CPP weirdness (#9945).
* Add export lists to some modules.David Feuer2014-12-271-1/+6
| | | | | | | | | | | | | | | | | | Summary: This makes it easier to see what is exported, and allows us to add non-exported top-level names. Reviewers: hvr, austin, ezyang Reviewed By: ezyang Subscribers: ezyang, carter, thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D551 GHC Trac Issues: #9852
* Be consistent with placement of Safe Haskell mode at top of fileDavid Terei2014-11-211-0/+1
|
* base: Manually unlit .lhs into .hs modulesHerbert Valerio Riedel2014-11-071-0/+98
This commit mostly converts literate comments into ordinary Haskell comments or sometimes even Haddock comments, while also removing literate comments in a few cases where they don't make much sense anymore. Moreover, in a few cases trailing whitespaces were removed as well. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D456