summaryrefslogtreecommitdiff
path: root/libraries/base/Numeric.hs
Commit message (Collapse)AuthorAgeFilesLines
* Implement the basics of hex floating point literalsIavor Diatchki2017-11-021-0/+48
| | | | | | | | | | | | | | | | | | | | | | | Implement hexadecmial floating point literals. The digits of the mantissa are hexadecimal. The exponent is written in base 10, and the base for the exponentiation is 2. Hexadecimal literals look a lot like ordinary decimal literals, except that they use hexadecmial digits, and the exponent is written using `p` rather than `e`. The specification of the feature is available here: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0004-hexFloats.rst For a discussion of the various choices: https://github.com/ghc-proposals/ghc-proposals/pull/37 Reviewers: mpickering, goldfire, austin, bgamari, hvr Reviewed By: bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D3066
* Loads of doc(test)sDavid Luposchainsky2017-08-171-0/+9
|
* Allow CallStacks to be frozenEric Seidel2015-12-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces "freezing," an operation which prevents further locations from being appended to a CallStack. Library authors may want to prevent CallStacks from exposing implementation details, as a matter of hygiene. For example, in ``` head [] = error "head: empty list" ghci> head [] *** Exception: head: empty list CallStack (from implicit params): error, called at ... ``` including the call-site of `error` in `head` is not strictly necessary as the error message already specifies clearly where the error came from. So we add a function `freezeCallStack` that wraps an existing CallStack, preventing further call-sites from being pushed onto it. In other words, ``` pushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack ``` Now we can define `head` to not produce a CallStack at all ``` head [] = let ?callStack = freezeCallStack emptyCallStack in error "head: empty list" ghci> head [] *** Exception: head: empty list CallStack (from implicit params): error, called at ... ``` --- 1. We add the `freezeCallStack` and `emptyCallStack` and update the definition of `CallStack` to support this functionality. 2. We add `errorWithoutStackTrace`, a variant of `error` that does not produce a stack trace, using this feature. I think this is a sensible wrapper function to provide in case users want it. 3. We replace uses of `error` in base with `errorWithoutStackTrace`. The rationale is that base does not export any functions that use CallStacks (except for `error` and `undefined`) so there's no way for the stack traces (from Implicit CallStacks) to include user-defined functions. They'll only contain the call to `error` itself. As base already has a good habit of providing useful error messages that name the triggering function, the stack trace really just adds noise to the error. (I don't have a strong opinion on whether we should include this third commit, but the change was very mechanical so I thought I'd include it anyway in case there's interest) 4. Updates tests in `array` and `stm` submodules Test Plan: ./validate, new test is T11049 Reviewers: simonpj, nomeata, goldfire, austin, hvr, bgamari Reviewed By: simonpj Subscribers: thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1628 GHC Trac Issues: #11049
* Implement phase 1 of expanded FloatingDan Doel2015-12-211-0/+1
| | | | | | | | | | | | | | | | - This part of the proposal is to add log1p, expm1, log1pexp and log1mexp to the Floating class, and export the full Floating class from Numeric Reviewers: ekmett, #core_libraries_committee, bgamari, hvr, austin Reviewed By: ekmett, #core_libraries_committee, bgamari Subscribers: Phyx, RyanGlScott, ekmett, thomie Differential Revision: https://phabricator.haskell.org/D1605 GHC Trac Issues: #11166
* Convert `/Since: .../` to new `@since ...` syntaxHerbert Valerio Riedel2014-12-161-2/+2
| | | | | | Starting with Haddock 2.16 there's a new built-in support for since-annotations Note: This exposes a bug in the `@since` implementation (see e.g. `Data.Bits`)
* Move `Maybe`-typedef into GHC.BaseHerbert Valerio Riedel2014-09-161-1/+0
| | | | | | | This is preparatory work for reintroducing SPECIALISEs that were lost in d94de87252d0fe2ae97341d186b03a2fbe136b04 Differential Revision: https://phabricator.haskell.org/D214
* Add Haddock `/Since: 4.7.0.0/` comments to new symbolsHerbert Valerio Riedel2013-09-211-0/+4
| | | | | | | | | | | | | | | | | | These annotations were added in such a way, that the line {{{ /Since: 4.7.0.0/ }}} represents the last paragraph of the Haddock comment. Maybe Haddock will have support for this meta-syntax at some point, and be able to inherited the since-version property to the children of an annotated symbol and display the since-version property in the rendered documentation only in cases when it's not visually obvious (for instance, when re-exporting documentation strings). Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Replaced Text.Printf with extensible printf, and made comcommitant changesBart Massey2013-09-171-3/+23
| | | | Signed-off-by: Joachim Breitner <mail@joachim-breitner.de>
* Constant-fold `__GLASGOW_HASKELL__` CPP conditionalsHerbert Valerio Riedel2013-09-171-7/+1
| | | | | | | | | | Now that HUGS and NHC specific code has been removed, this commit "folds" the now redundant `#if((n)def)`s containing `__GLASGOW_HASKELL__`. This renders `base` officially GHC only. This commit also removes redundant `{-# LANGUAGE CPP #-}`. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Remove Hugs98 specific codeHerbert Valerio Riedel2013-09-171-5/+0
| | | | | | | For rationale. see http://permalink.gmane.org/gmane.comp.lang.haskell.ghc.devel/2349 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Remove commented types in module export listsIan Lynagh2012-10-271-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These comments are rather less useful now that haddock can give docs with the same informatino in the module synopsis. Having to maintain them when making changes to the library is a pain, and when people forget about doing so there is nothing that checks that the comments are right, so mistakes tend to linger. Of the comments that my script detected, 78 of 684 were already incorrect in one way or another, e.g. missing context: Text.Show.showsPrec Comment type: Int -> a -> ShowS Actual type: Show a => Int -> a -> ShowS wrong context: Numeric.readInt Comment type: Integral a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a Actual type: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a not following a class change (e.g. Num losing its Eq superclass): Text.Read.Lex.readOctP Comment type: Num a => ReadP a Actual type: (Eq a, Num a) => ReadP a not following the Exceptions change: GHC.Conc.childHandler Comment type: Exception -> IO () Actual type: SomeException -> IO () or just always been wrong: GHC.Stable.deRefStablePtr Comment type: StablePtr a -> a Actual type: StablePtr a -> IO a
* Refactor number lexing; part of #5688Ian Lynagh2012-03-011-3/+2
| | | | | This doesn't change the behaviour yet, but I think it's a step in the right direction.
* Remove the Eq superclass of NumIan Lynagh2011-10-121-3/+3
|
* Remove the Show superclass of NumIan Lynagh2011-10-121-3/+3
|
* SafeHaskell: Added SafeHaskell to baseDavid Terei2011-06-181-0/+1
|
* Use explicit language extensions & remove extension fields from base.cabalsimonpj@microsoft.com2011-01-281-1/+2
| | | | | | | | | | Add explicit {-# LANGUAGE xxx #-} pragmas to each module, that say what extensions that module uses. This makes it clearer where different extensions are used in the (large, variagated) base package. Now base.cabal doesn't need any extensions field Thanks to Bas van Dijk for doing all the work.
* Fix warningsIan Lynagh2008-08-051-7/+7
|
* Avoid using deprecated flagsIan Lynagh2008-06-161-1/+1
|
* untabifyDon Stewart2008-03-031-2/+2
|
* untabifyDon Stewart2008-02-281-42/+42
|
* [project @ 2005-01-11 16:04:08 by simonmar]simonmar2005-01-111-1/+1
| | | | Use OPTIONS_GHC instead of OPTIONS
* [project @ 2004-07-23 11:34:31 by ross]ross2004-07-231-14/+73
| | | | docs only
* [project @ 2004-03-30 17:54:28 by ross]ross2004-03-301-2/+2
| | | | fix a warning
* [project @ 2003-12-12 18:29:26 by sof]sof2003-12-121-10/+11
| | | | | | | | showIntAtBase: - implementation uses quotRem [where the remainder isn't always non-negative -- ditto for divMod, so there's no trivial fix], negative bases aren't supported; catch this. - separate argument validity checking from actual digitisation.
* [project @ 2003-07-21 09:26:23 by simonmar]simonmar2003-07-211-4/+4
| | | | | | | | | | Fix showIntAtBase to match the report. Its signature was previously showIntAtBase :: Integral a => a -> (a -> Char) -> a -> ShowS and is now: showIntAtBase :: Integral a => a -> (a -> Char) -> a -> ShowS
* [project @ 2003-07-16 10:55:20 by simonmar]simonmar2003-07-161-21/+3
| | | | | | | - Make showHex and showOct match the report (don't add leading "Ox" or "Oo"). - Remove showBin, which isn't specified by the report.
* [project @ 2002-09-09 03:50:38 by sof]sof2002-09-091-1/+1
| | | | (hugs only): PrelImpl -> Hugs.Prelude
* [project @ 2002-09-08 02:35:33 by sof]sof2002-09-081-0/+1
| | | | Hugs updates + fixes
* [project @ 2002-07-17 10:47:01 by ross]ross2002-07-171-233/+3
| | | | | | | Make the libraries' Numeric module usable by Hugs. Also deleted a chunk of code inside #ifdef __HUGS__ -- this was unused, and the copy in Hugs (now Hugs.Numeric) has since been improved. (Since these functions are portable, ideally they would be merged with the versions in GHC.Float)
* [project @ 2002-06-05 14:08:24 by simonpj]simonpj2002-06-051-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------ Fix the (new) lexer, and make the derived read and show code work according to the new H98 report ------------------------------------------------ The new lexer, based on Koen's cunning parser (Text.ParserCombinators.ReadP) wasn't quite right. It's all very cool now. In particular: * The H98 "lex" function should return the exact string parsed, and it now does, aided by the new combinator ReadP.gather. * As a result the Text.Read.Lex Lexeme type is much simpler than before data Lexeme = Char Char -- Quotes removed, | String String -- escapes interpreted | Punc String -- Punctuation, eg "(", "::" | Ident String -- Haskell identifiers, e.g. foo, baz | Symbol String -- Haskell symbols, e.g. >>, % | Int Integer | Rat Rational | EOF deriving (Eq,Show) * Multi-character punctuation, like "::" was getting lexed as a Symbol, but it should be a Punc. * Parsing numbers wasn't quite right. "1..n" got it confused because it got committed to a decimal point and then found a second '.'. * The new H98 spec for Show is there, which ignores associativity.
* [project @ 2002-05-15 12:16:11 by simonmar]simonmar2002-05-151-12/+4
| | | | Fix non-Haddockish comments
* [project @ 2002-05-09 13:16:29 by simonmar]simonmar2002-05-091-1/+1
| | | | Rename libraries/core to libraries/base in the module headers.
* [project @ 2002-04-26 13:34:05 by simonmar]simonmar2002-04-261-2/+0
| | | | | Remove \$Id\$ from all files: it isn't particularly useful (see previous discussion on cvs-ghc@haskell.org), and it confuses Haddock.
* [project @ 2002-04-24 16:31:37 by simonmar]simonmar2002-04-241-2/+2
| | | | | Add the single character '|' to the header comment of each module so that Haddock will parse it as the module documentation.
* [project @ 2002-04-11 12:03:43 by simonpj]simonpj2002-04-111-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------- Mainly derived Read ------------------- This commit is a tangle of several things that somehow got wound up together, I'm afraid. The main course ~~~~~~~~~~~~~~~ Replace the derived-Read machinery with Koen's cunning new parser combinator library. The result should be * much smaller code sizes from derived Read * faster execution of derived Read WARNING: I have not thoroughly tested this stuff; I'd be glad if you did! All the hard work is done, but there may be a few nits. The Read class gets two new methods, not exposed in the H98 inteface of course: class Read a where readsPrec :: Int -> ReadS a readList :: ReadS [a] readPrec :: ReadPrec a -- NEW readListPrec :: ReadPrec [a] -- NEW There are the following new libraries: Text.ParserCombinators.ReadP Koens combinator parser Text.ParserCombinators.ReadPrec Ditto, but with precedences Text.Read.Lex An emasculated lexical analyser that provides the functionality of H98 'lex' TcGenDeriv is changed to generate code that uses the new libraries. The built-in instances of Read (List, Maybe, tuples, etc) use the new libraries. Other stuff ~~~~~~~~~~~ 1. Some fixes the the plumbing of external-core generation. Sigbjorn did most of the work earlier, but this commit completes the renaming and typechecking plumbing. 2. Runtime error-generation functions, such as GHC.Err.recSelErr, GHC.Err.recUpdErr, etc, now take an Addr#, pointing to a UTF8-encoded C string, instead of a Haskell string. This makes the *calls* to these functions easier to generate, and smaller too, which is a good thing. In particular, it means that MkId.mkRecordSelectorId doesn't need to be passed "unpackCStringId", which was GRUESOME; and that in turn means that tcTypeAndClassDecls doesn't need to be passed unf_env, which is a very worthwhile cleanup. Win/win situation. 3. GHC now faithfully translates do-notation using ">>" for statements with no binding, just as the report says. While I was there I tidied up HsDo to take a list of Ids instead of 3 (but now 4) separate Ids. Saves a bit of code here and there. Also introduced Inst.newMethodFromName to package a common idiom.
* [project @ 2002-02-12 10:52:18 by simonmar]simonmar2002-02-121-4/+7
| | | | | Place this below the Prelude in the dependency tree, so we can import it in Foreign.Ptr without creating a loop.
* [project @ 2002-02-05 17:32:24 by simonmar]simonmar2002-02-051-13/+7
| | | | | | - Merging from ghc/lib/std - Add System.IO.Error - Now builds without --make, so we can do -split-objs
* [project @ 2002-01-02 14:40:09 by simonmar]simonmar2002-01-021-5/+1
| | | | Make this compile again, and update with latest changes from hslibs/lang.
* [project @ 2001-08-02 13:30:36 by simonmar]simonmar2001-08-021-2/+6
| | | | Don't export non-H98 functions
* [project @ 2001-07-04 12:07:27 by simonmar]simonmar2001-07-041-0/+367
Add Numeric library here for the time being. This is a combination of the H98 Numeric library and a few functions from GHC's NumExts.