summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Exception
Commit message (Collapse)AuthorAgeFilesLines
* Move absentError into ghc-prim.Andreas Klebinger2021-02-261-3/+3
| | | | | | | | | | | | When using -fdicts-strict we generate references to absentError while compiling ghc-prim. However we always load ghc-prim before base so this caused linker errors. We simply solve this by moving absentError into ghc-prim. This does mean it's now a panic instead of an exception which can no longer be caught. But given that it should only be thrown if there is a compiler error that seems acceptable, and in fact we already do this for absentSumFieldError which has similar constraints.
* Apply 1 suggestion(s) to 1 file(s)Marcin Szamotulski2021-02-131-7/+15
|
* Improve bracket documentationMarcin Szamotulski2021-02-131-0/+8
|
* Remove all the unnecessary LANGUAGE pragmasHécate2020-08-051-10/+10
|
* Fix unboxed-sums GC ptr-slot rubbish value (#17791)Sylvain Henry2020-05-091-5/+1
| | | | | | | This patch allows boot libraries to use unboxed sums without implicitly depending on `base` package because of `absentSumFieldError`. See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make
* Fix typo in documentation of Base.hs.Matthias Braun2019-12-051-1/+1
|
* Fix #15038Ömer Sinan Ağacan2018-05-101-1/+5
| | | | | | | | | | | | | | | | | | | | | We introduce a new Id for unused pointer values in unboxed sums that is not CAFFY. Because the Id is not CAFFY it doesn't make non-CAFFY definitions CAFFY, fixing #15038. To make sure anything referenced by the new id will be retained we get a stable pointer to in on RTS startup. Test Plan: Passes validate Reviewers: simonmar, simonpj, hvr, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15038 Differential Revision: https://phabricator.haskell.org/D4680
* Kill off irrefutable pattern errorsDavid Feuer2018-01-151-3/+2
| | | | | | | | | | | | | | | | | Distinguishing between "refutable" and "irrefutable" patterns (as described by the Haskell Report) in incomplete pattern errors was more confusing than helpful. Remove references to irrefutable patterns. Reviewers: hvr, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #14569 Differential Revision: https://phabricator.haskell.org/D4261
* Add custom exception for fixIODavid Feuer2017-11-021-0/+1
| | | | | | | | | | | | | | | | Traditionally, `fixIO f` throws `BlockedIndefinitelyOnMVar` if `f` is strict. This is not particularly friendly, since the `MVar` in question is just part of the way `fixIO` happens to be implemented. Instead, throw a new `FixIOException` with a better explanation of the problem. Reviewers: austin, hvr, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #14356 Differential Revision: https://phabricator.haskell.org/D4113
* Change catch# demand signatureDavid Feuer2017-03-011-39/+0
| | | | | | | | | | | | | | | | | | * Give `catch#` a lazy demand signature, to make it more honest. * Make `catchException` and `catchAny` force their arguments so they actually behave as advertised. * Use `catch` rather than `catchException` in `forkIO`, `forkOn`, and `forkOS` to avoid losing exceptions. Fixes #13330 Reviewers: rwbarton, simonpj, simonmar, bgamari, hvr, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3244
* Overhaul of Compact Regions (#12455)Simon Marlow2016-12-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit makes various improvements and addresses some issues with Compact Regions (aka Compact Normal Forms). This was the most important thing I wanted to fix. Compaction previously prevented GC from running until it was complete, which would be a problem in a multicore setting. Now, we compact using a hand-written Cmm routine that can be interrupted at any point. When a GC is triggered during a sharing-enabled compaction, the GC has to traverse and update the hash table, so this hash table is now stored in the StgCompactNFData object. Previously, compaction consisted of a deepseq using the NFData class, followed by a traversal in C code to copy the data. This is now done in a single pass with hand-written Cmm (see rts/Compact.cmm). We no longer use the NFData instances, instead the Cmm routine evaluates components directly as it compacts. The new compaction is about 50% faster than the old one with no sharing, and a little faster on average with sharing (the cost of the hash table dominates when we're doing sharing). Static objects that don't (transitively) refer to any CAFs don't need to be copied into the compact region. In particular this means we often avoid copying Char values and small Int values, because these are static closures in the runtime. Each Compact# object can support a single compactAdd# operation at any given time, so the Data.Compact library now enforces mutual exclusion using an MVar stored in the Compact object. We now get exceptions rather than killing everything with a barf() when we encounter an object that cannot be compacted (a function, or a mutable object). We now also detect pinned objects, which can't be compacted either. The Data.Compact API has been refactored and cleaned up. A new compactSize operation returns the size (in bytes) of the compact object. Most of the documentation is in the Haddock docs for the compact library, which I've expanded and improved here. Various comments in the code have been improved, especially the main Note [Compact Normal Forms] in rts/sm/CNF.c. I've added a few tests, and expanded a few of the tests that were there. We now also run the tests with GHCi, and in a new test way that enables sanity checking (+RTS -DS). There's a benchmark in libraries/compact/tests/compact_bench.hs for measuring compaction speed and comparing sharing vs. no sharing. The field totalDataW in StgCompactNFData was unnecessary. Test Plan: * new unit tests * validate * tested manually that we can compact Data.Aeson data Reviewers: gcampax, bgamari, ezyang, austin, niteria, hvr, erikd Subscribers: thomie, simonpj Differential Revision: https://phabricator.haskell.org/D2751 GHC Trac Issues: #12455
* Add @since annotations to base instancesSeraphime Kirkovski2016-06-061-0/+16
| | | | | | | | | | | | | | | | | | 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
* Make `catch` lazy in the actionBen Gamari2016-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | Previously ```lang=haskell catch (error "uh oh") (\(_ :: SomeException) -> print "it failed") ``` would unexpectedly fail with "uh oh" instead of the handler being run due to the strictness of `catch` in its first argument. See #11555 for details. Test Plan: Validate Reviewers: austin, hvr, simonpj Reviewed By: simonpj Subscribers: simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1973 GHC Trac Issues: #11555
* Make TypeError a newtype, add changelog entryRyanGlScott2016-02-021-1/+3
| | | | | | | | | | | | | | | | | | Summary: Phab:D866 added the `TypeError` datatype to `Control.Exception` to represent the error that is thrown when `-fdefer-type-errors` is on, but a changelog entry for it was never added. In addition, it should probably be a newtype. Reviewers: austin, hvr, KaneTW, bgamari Reviewed By: KaneTW, bgamari Subscribers: thomie, KaneTW Differential Revision: https://phabricator.haskell.org/D1873 GHC Trac Issues: #10284
* Allow CallStacks to be frozenEric Seidel2015-12-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Associate ErrorCall pattern with ErrorCall typeHerbert Valerio Riedel2015-12-081-2/+1
| | | | | | | | | | | | | | | | | | | This way, import Control.Exception (ErrorCall(ErrorCall)) or import Control.Exception (ErrorCall(..)) work as expected, and import the `ErrorCall` compatibility pattern as well. When #5273 was implemented, it wasn't possible yet to associated patterns with their types (see #10653). Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1588
* Use IP based CallStack in error and undefinedEric Seidel2015-09-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch modifies `error`, `undefined`, and `assertError` to use implicit call-stacks to provide better error messages to users. There are a few knock-on effects: - `GHC.Classes.IP` is now wired-in so it can be used in the wired-in types for `error` and `undefined`. - `TysPrim.tyVarList` has been replaced with a new function `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce subtle bugs when you need tyvars of different kinds. The naive ``` tv1 = head $ tyVarList kind1 tv2 = head $ tyVarList kind2 ``` would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions would be applied incorrectly, treating `tv1` and `tv2` as the same tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds and producing a single tyvar of each kind. - The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in ghc-prim. - The type `GHC.Exception.ErrorCall` has a new constructor `ErrorCallWithLocation` that takes two `String`s instead of one, the 2nd one being arbitrary metadata about the error (but usually the call-stack). A bi-directional pattern synonym `ErrorCall` continues to provide the old API. Updates Cabal, array, and haddock submodules. Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari Reviewed By: simonpj Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter, liyang, bgamari, thomie Differential Revision: https://phabricator.haskell.org/D861 GHC Trac Issues: #5273
* Make Exception datatypes into newtypesRyanGlScott2015-08-051-5/+5
| | | | | | | | | | | | | | | Certain instances of `Exception` are simply datatypes with only one argument, which should be `newtype`s. Reviewers: ekmett, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1131 GHC Trac Issues: #10738
* Deferred type errors now throw TypeError (#10284)David Kraeutmann2015-07-071-2/+16
| | | | | | | | | | | | | | | | | | | | | | Depends on D864. Previous behaviour was ErrorCall, which might mask issues in tests using -fdefer-type-errors Signed-off-by: David Kraeutmann <kane@kane.cx> Test Plan: Test whether the error thrown is indeed TypeError and not ErrorCall. Reviewers: hvr, nomeata, austin Reviewed By: nomeata, austin Subscribers: nomeata, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D866 GHC Trac Issues: #10284
* base: drop redundant Typeable derivingsHerbert Valerio Riedel2015-03-071-9/+8
| | | | | | | | | | | Thanks to #9858 `Typeable` doesn't need to be explicitly derived anymore. This also makes `AutoDeriveTypeable` redundant, as well as some imports of `Typeable` (removal of whose may be beneficial to #9707). This commit removes several such now redundant use-sites in `base`. Reviewed By: austin, ekmett Differential Revision: https://phabricator.haskell.org/D712
* Per-thread allocation counters and limitsSimon Marlow2014-11-121-0/+1
| | | | | | | | This reverts commit f0fcc41d755876a1b02d1c7c79f57515059f6417. New changes: now works on 32-bit platforms too. I added some basic support for 64-bit subtraction and comparison operations to the x86 NCG.
* `M-x delete-trailing-whitespace` & `M-x untabify`Herbert Valerio Riedel2014-09-241-2/+2
| | | | ...several modules in `base` recently touched by me
* 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
* Replace DeriveDataTypeable by AutoDeriveTypeableHerbert Valerio Riedel2014-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a first step towards addressing #9111 This results in the following additional Typeable (exported) instances being generated (list was compiled by diff'ing hoogle txt output): instance Typeable CFile instance Typeable 'CFile instance Typeable CFpos instance Typeable 'CFpos instance Typeable CJmpBuf instance Typeable 'CJmpBuf instance Typeable ChItem instance Typeable QSem instance Typeable ID instance Typeable 'ID instance Typeable CONST instance Typeable Qi instance Typeable Qr instance Typeable Mp instance Typeable ConstrRep instance Typeable Fixity instance Typeable 'Prefix instance Typeable 'Infix instance Typeable Constr instance Typeable DataType instance Typeable DataRep instance Typeable Data instance Typeable HasResolution instance Typeable IsList Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Revert "Per-thread allocation counters and limits"Simon Marlow2014-05-041-1/+0
| | | | | | | | Problems were found on 32-bit platforms, I'll commit again when I have a fix. This reverts the following commits: 54b31f744848da872c7c6366dea840748e01b5cf b0534f78a73f972e279eed4447a5687bd6a8308e
* Per-thread allocation counters and limitsSimon Marlow2014-05-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This tracks the amount of memory allocation by each thread in a counter stored in the TSO. Optionally, when the counter drops below zero (it counts down), the thread can be sent an asynchronous exception: AllocationLimitExceeded. When this happens, given a small additional limit so that it can handle the exception. See documentation in GHC.Conc for more details. Allocation limits are similar to timeouts, but - timeouts use real time, not CPU time. Allocation limits do not count anything while the thread is blocked or in foreign code. - timeouts don't re-trigger if the thread catches the exception, allocation limits do. - timeouts can catch non-allocating loops, if you use -fno-omit-yields. This doesn't work for allocation limits. I couldn't measure any impact on benchmarks with these changes, even for nofib/smp.
* Make `<Typeable.h>` obsolete and refactor away its useHerbert Valerio Riedel2013-09-171-17/+8
| | | | | | | | | | | With GHC 7.8's PolyKinds the macros in `<Typeable.h>` are no longer of any use, and their use is clearly obsolete. The sites using those macros are replaced by auto-derivations of `Typeable` instances. This reduces reliance on the CPP extension and the compile dependency on `Typeable.h` in a couple of modules. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Constant-fold `__GLASGOW_HASKELL__` CPP conditionalsHerbert Valerio Riedel2013-09-171-25/+0
| | | | | | | | | | 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-161/+3
| | | | | | | For rationale. see http://permalink.gmane.org/gmane.comp.lang.haskell.ghc.devel/2349 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Remove blocked (deprecated since 7.2)Ian Lynagh2013-02-191-11/+0
|
* Remove block and unblock (deprecated since GHC 7.0)Ian Lynagh2013-02-191-6/+0
|
* Remove nhc98-specific files and contentIan Lynagh2013-02-151-100/+1
|
* Make a class for asynchronous exceptions in the exception hierarchySimon Marlow2012-12-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | Right now, we only have data AsyncException = StackOverflow | HeapOverflow | ThreadKilled | ... so it is not possible to add another async exception. For instance, the Timeout exception in System.Timeout should really be an async exception. This patch adds a superclass for all async exceptions: data SomeAsyncException = forall e . Exception e => SomeAsyncException e deriving Typeable and makes the existing AsyncException and Timeout children of SomeAsyncException in the hierarchy.
* Remove an out-of-date commentIan Lynagh2012-11-171-5/+0
|
* Remove out-of-date docs about Prelude.catch; fixes #7348Ian Lynagh2012-10-201-16/+0
|
* fix cross-ref to "Catching all exceptions" section (#5546)Simon Marlow2011-10-181-2/+2
|
* SafeHaskell: Added SafeHaskell to baseDavid Terei2011-06-181-1/+2
|
* Big patch to improve Unicode support in GHC. Validated on OS X and Windows, thisMax Bolingbroke2011-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | patch series fixes #5061, #1414, #3309, #3308, #3307, #4006 and #4855. The major changes are: 1) Make Foreign.C.String.*CString use the locale encoding This change follows the FFI specification in Haskell 98, which has never actually been implemented before. The functions exported from Foreign.C.String are partially-applied versions of those from GHC.Foreign, which allows the user to supply their own TextEncoding. We also introduce foreignEncoding as the name of the text encoding that follows the FFI appendix in that it transliterates encoding errors. 2) I also changed the code so that mkTextEncoding always tries the native-Haskell decoders in preference to those from iconv, even on non-Windows. The motivation here is simply that it is better for compatibility if we do this, and those are the ones you get for the utf* and latin1* predefined TextEncodings anyway. 3) Implement surrogate-byte error handling mode for TextEncoding This implements PEP383-like behaviour so that we are able to roundtrip byte strings through Strings without loss of information. The withFilePath function now uses this encoding to get to/from CStrings, so any code that uses that will get the right PEP383 behaviour automatically. 4) Implement three other coding failure modes: ignore, throw error, transliterate These mimic the behaviour of the GNU Iconv extensions.
* For GHC, implement the Typeable.hs macros using standalone derivingIan Lynagh2011-04-241-0/+3
| | | | | | As well as being more pleasant, this fixes #1841: Data.Typeable: Instances of basic types don't provide qualified strings to mkTyCon
* Use explicit language extensions & remove extension fields from base.cabalsimonpj@microsoft.com2011-01-281-1/+1
| | | | | | | | | | 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.
* Replaced some throws to throwIOs where the type is IOBas van Dijk2010-09-241-4/+4
|
* Add absentError. simonpj@microsoft.com2010-09-141-1/+4
| | | | | | | | | | | | | This patch accompanies the HEAD patch: Tue Sep 14 12:38:27 BST 2010 simonpj@microsoft.com * Make absent-arg wrappers work for unlifted types (fix Trac #4306) Previously we were simply passing arguments of unlifted type to a wrapper, even if they were absent, which was stupid. See Note [Absent error Id] in WwLib.
* Integrated new I/O managerSimon Marlow2010-08-101-1/+1
| | | | (patch originally by Johan Tibell <johan.tibell@gmail.com>, minor merging by me)
* Allow nhc98 to cope with recent changes to Control.Exception.Malcolm.Wallace@me.com2010-07-101-1/+6
|
* New asynchronous exception control API (base parts)Simon Marlow2010-07-081-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed on the libraries/haskell-cafe mailing lists http://www.haskell.org/pipermail/libraries/2010-April/013420.html This is a replacement for block/unblock in the asychronous exceptions API to fix a problem whereby a function could unblock asynchronous exceptions even if called within a blocked context. The new terminology is "mask" rather than "block" (to avoid confusion due to overloaded meanings of the latter). The following is the new API; the old API is deprecated but still available for the time being. Control.Exception ----------------- mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b mask_ :: IO a -> IO a uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b uninterruptibleMask_ :: IO a -> IO getMaskingState :: IO MaskingState data MaskingState = Unmasked | MaskedInterruptible | MaskedUninterruptible Control.Concurrent ------------------ forkIOUnmasked :: IO () -> IO ThreadId
* Tweak docsIan Lynagh2010-03-121-1/+1
|
* Documentation fixes in Control.ExceptionBas van Dijk2010-03-011-2/+2
|
* Control.Exception.Base no longer has any orphansIan Lynagh2009-11-231-1/+0
|
* Fix gratuitous breakage of nhc98 in Control.Exception.Base.Malcolm.Wallace@cs.york.ac.uk2009-10-091-2/+2
|
* Address #3310Simon Marlow2009-08-301-10/+10
| | | | | | | | | | | | | | - Rename BlockedOnDeadMVar -> BlockedIndefinitelyOnMVar - Rename BlockedIndefinitely -> BlockedIndefinitelyOnSTM - instance Show BlockedIndefinitelyOnMVar is now "blocked indefinitely in an MVar operation" - instance Show BlockedIndefinitelyOnSTM is now "blocked indefinitely in an STM transaction" clients using Control.OldException will be unaffected (the new exceptions are mapped to the old names). However, for base4-compat we'll need to make a version of catch/try that does a similar mapping.