summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Monad
Commit message (Collapse)AuthorAgeFilesLines
* Add instances for GHC.Tuple.SoloBen Gamari2021-01-272-0/+12
| | | | | | | | | | | | | | | The `Applicative` instance is the most important one (for array/vector/sequence indexing purposes), but it deserves all the usual ones. T12545 does silly 1% wibbles both ways, it seems, maybe depending on architecture. Metric Increase: T12545 Metric Decrease: T12545
* Remove redundant "do", "return" and language extensions from baseHécate2020-09-231-1/+1
|
* Add an example to liftIO and explain its purposeHécate2020-04-091-0/+34
|
* Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hsMaxim Koltsov2020-04-031-3/+3
|
* Require GHC 8.8 as the minimum compiler for bootstrappingRyan Scott2020-03-311-6/+5
| | | | | | | | This allows us to remove several bits of CPP that are either always true or no longer reachable. As an added bonus, we no longer need to worry about importing `Control.Monad.Fail.fail` qualified to avoid clashing with `Control.Monad.fail`, since the latter is now the same as the former.
* base: Ensure that failIO isn't SOURCE importedBen Gamari2019-11-011-2/+1
| | | | | | | | | failIO has useful information in its demand signature (specifically that it bottoms) which is hidden if it is SOURCE imported, as noted in #16588. Rejigger things such that we don't SOURCE import it. Metric Increase: T13701
* Data.Ord: give a field name getDown to DownFumiaki Kinoshita2019-06-181-1/+0
|
* base: Remove `Monad(fail)` method and reexport `MonadFail(fail)` insteadHerbert Valerio Riedel2019-03-221-3/+0
| | | | | | As per https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail Coauthored-by: Ben Gamari <ben@well-typed.com>
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-152-2/+2
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Remove OPTIONS_HADDOCK hide in favour for not-homeAdam Sandberg Eriksson2019-01-062-2/+2
| | | | GHC Trac Issues: #15447
* Doc-only fixesAlec Theriault2018-11-222-13/+12
| | | | | | * laws are capitalized definition lists, no emphasis on the labels * adds missing hyperlinks * fixes other misc. Haddock markup issues.
* docs: "state transformer" -> "state monad" / "ST" (whichever is meant)Artem Pelenitsyn2018-08-214-11/+11
| | | | | | | | | | | | | | FIxes #15189. Reviewers: hvr, bgamari, simonmar, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #15189 Differential Revision: https://phabricator.haskell.org/D5019
* Fix ambiguous/out-of-scope Haddock identifiersAlec Theriault2018-08-213-4/+4
| | | | | | | | | | | | | | | | | 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
* Harden fixSTDavid Feuer2018-07-212-4/+54
| | | | | | | | | | | | | | | | Trac #15349 reveals that lazy blackholing can cause trouble for `fixST` much like it can for `fixIO`. Make `fixST` work just like `fixIO`. Reviewers: simonmar, hvr, bgamari Reviewed By: simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15349 Differential Revision: https://phabricator.haskell.org/D4948
* base: Add missing instances for Data.Ord.DownBen Gamari2018-06-192-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically: * MonadFix * MonadZip * Data * Foldable * Traversable * Eq1 * Ord1 * Read1 * Show1 * Generic * Generic1 Fixes #15098. Reviewers: RyanGlScott, hvr Reviewed By: RyanGlScott Subscribers: sjakobi, rwbarton, thomie, ekmett, carter GHC Trac Issues: #15098 Differential Revision: https://phabricator.haskell.org/D4870
* base: Introduce Data.Monoid.Apchessai2018-05-271-1/+5
| | | | | This data type witnesses the lifting of a monoid into an applicative pointwise.
* Fix documentation and comment issuesCyd Parser2017-11-031-1/+1
|
* Move NonEmpty definition into GHC.BaseHerbert Valerio Riedel2017-09-042-1/+16
| | | | | | This is a preparatory refactoring for Semigroup=>Monoid as it prevents a messy .hs-boot file which would interact inconveniently with the buildsystem...
* Typos in comments and manual [ci skip]Gabor Greif2017-06-281-1/+1
|
* Make unsafeInterleaveST less unsafeDavid Feuer2017-03-222-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | * Make `unsafeInterleaveST` use `noDuplicate#` like `unsafeInterleaveIO` does to prevent the suspended action from being run in two threads. * In order to accomplish this without `unsafeCoerce#`, generalize the type of `noDuplicate#`. * Add `unsafeDupableInterleaveST` to get the old behavior. * Document unsafe `ST` functions and clean up some related documentation. Fixes #13457 Reviewers: austin, hvr, bgamari, ekmett Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3370
* Add liftA2 to Applicative classDavid Feuer2017-02-051-0/+15
| | | | | | | | | | | | | | | | * Make `liftA2` a method of `Applicative`. * Add explicit `liftA2` definitions to instances in `base`. * Add explicit invocations in `base`. Reviewers: ekmett, bgamari, RyanGlScott, austin, hvr Reviewed By: RyanGlScott Subscribers: ekmett, RyanGlScott, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3031
* Attempt to make lazy ST thread safeDavid Feuer2017-02-031-24/+118
| | | | | | | | | | | | | | | | | | | Use `noDuplicate#` to prevent lazy `ST` thunks from being evaluated in multiple GHC threads. Some lazy `ST` functions added laziness that did not seem to be useful (e.g., creating lazy pairs that will never be matched unless one of their components is demanded). Stripped that out. Reviewers: ekmett, simonpj, bgamari, simonmar, austin, hvr Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3038 GHC Trac Issues: #11760
* Generalize the type of runRW#David Feuer2017-01-251-2/+1
| | | | | | | | | | | | | | | | | | | | | * Generalize the type of `runRW#` to allow arbitrary return types. * Use `runRW#` to implement `Control.Monad.ST.Lazy.runST` (this provides evidence that it actually works properly with the generalized type). * Adjust the type signature in the definition of `oneShot` to match the one it is given in `MkId`. Reviewers: simonmar, austin, bgamari, hvr Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3012 GHC Trac Issues: #13178
* Add Bifoldable and Bitraversable to baseRyan Scott2016-06-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds `Data.Bifoldable` and `Data.Bitraversable` from the `bifunctors` package to `base`, completing the migration started in D336. This is fairly straightforward, although there were a suprising amount of reinternal organization in `base` that was needed for this to happen: * `Data.Foldable`, `Data.Traversable`, `Data.Bifoldable`, and `Data.Bitraversable` share some nonexported datatypes (e.g., `StateL`, `StateR`, `Min`, `Max`, etc.) to implement some instances. To avoid code duplication, I migrated this internal code to a new hidden module, `Data.Functor.Utils` (better naming suggestions welcome). * `Data.Traversable` and `Data.Bitraversable` also make use of an identity newtype, so I modified them to use `Data.Functor.Identity.Identity`. This has a ripple effect on several other modules, since I had to move instances around in order to avoid dependency cycles. Fixes #10448. Reviewers: ekmett, hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2284 GHC Trac Issues: #9682, #10448
* Add @since annotations to base instancesSeraphime Kirkovski2016-06-065-0/+38
| | | | | | | | | | | | | | | | | | 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
* Missing Proxy instances, make U1 instance more Proxy-likeRyanGlScott2016-02-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This accomplishes three things: * Adds missing `Alternative`, `MonadPlus`, and `MonadZip` instances for `Proxy` * Adds a missing `MonadPlus` instance for `U1` * Changes several existing `U1` instances to use lazy pattern-matching, exactly how `Proxy` does it (in case we ever replace `U1` with `Proxy`). This is technically a breaking change (albeit an extremely minor one). Test Plan: ./validate Reviewers: austin, ekmett, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1962 GHC Trac Issues: #11650
* Add more type class instances for GHC.GenericsRyanGlScott2016-02-252-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GHC.Generics provides several representation data types that have obvious instances of various type classes in base, along with various other types of meta-data (such as associativity and fixity). Specifically, instances have been added for the following type classes (where possible): - Applicative - Data - Functor - Monad - MonadFix - MonadPlus - MonadZip - Foldable - Traversable - Enum - Bounded - Ix - Generic1 Thanks to ocharles for starting this! Test Plan: Validate Reviewers: ekmett, austin, hvr, bgamari Reviewed By: bgamari Subscribers: RyanGlScott, thomie Differential Revision: https://phabricator.haskell.org/D1937 GHC Trac Issues: #9043
* Allow CallStacks to be frozenEric Seidel2015-12-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* update link to MonadFail proposalHerbert Valerio Riedel2015-11-251-1/+2
| | | | [skip ci]
* base: Add new Control.Monad.Fail module (re #10751)Herbert Valerio Riedel2015-11-031-0/+77
| | | | | | | | | | | | | | | | | This is based on David's initial patch augmented by more extensive Haddock comments. This has been broken out of D1248 to reduce its size by splitting the patch into smaller logical pieces. On its own, this new module does nothing interesting yet. Later patches will add support for a different desugaring of `do`-blocks, at which point the new `MonadFail` class will become more useful. Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D1424
* Move Control.Monad.IO.Class to base from transformersRyanGlScott2015-10-171-0/+36
| | | | | | | | | | | | | | | | | | | | | See Trac #10773 Remove Control.Monad.IO.Class from `transformers`. Updates `transformers` submodule. See Trac #10773 Test Plan: ./validate Reviewers: ekmett, hvr, bgamari, austin Reviewed By: hvr, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1147 GHC Trac Issues: #10773
* base: MRP-refactoring of AMP instancesHerbert Valerio Riedel2015-10-121-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This refactors `(>>)`/`(*>)`/`return`/`pure` methods into normal form. The redundant explicit `return` method definitions are dropped altogether. The explicit `(>>) = (*>)` definitions can't be removed yet, as the default implementation of `(>>)` is still in terms of `(*>)` (even though that should have been changed according to the AMP but wasn't -- see note in GHC.Base for details why this had to be postponed) A nofib comparision shows this refactoring to result in minor runtime improvements (unless those are within normal measurement fluctuations): Program Size Allocs Runtime Elapsed TotalMem ------------------------------------------------------------------------- Min -0.0% -0.0% -1.6% -3.9% -1.1% Max -0.0% +0.0% +0.5% +0.5% 0.0% Geometric Mean -0.0% -0.0% -0.4% -0.5% -0.0% Full `nofib` report at https://phabricator.haskell.org/P68 Reviewers: quchen, alanz, austin, #core_libraries_committee, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1316
* Add more MonadZip instancesOleg Grenrus2015-03-172-2/+28
| | | | | | | | | | | | | | Summary: Add MonadZip Alt and MonadFix Alt instances Reviewers: ekmett, dfeuer, hvr, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D716 GHC Trac Issues: #10107
* Add various instances to newtypes in Data.MonoidOleg Grenrus2015-03-031-0/+18
| | | | | | | | | | | | | | | | | | | | | | | Summary: Add Functor instances for Dual, Sum and Product Add Foldable instances for Dual, Sum and Product Add Traversable instances for Dual, Sum and Product Add Foldable and Traversable instances for First and Last Add Applicative, Monad instances to Dual, Sum, Product Add MonadFix to Data.Monoid wrappers Derive Data for Identity Add Data instances to Data.Monoid wrappers Add Data (Alt f a) instance Reviewers: ekmett, dfeuer, hvr, austin Reviewed By: dfeuer, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D673 GHC Trac Issues: #10107
* Revert "Add export lists to some modules."Austin Seipp2015-01-191-1/+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/+1
| | | | | | | | | | | | | | | | | | 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
* Update Control.Monad.ST.* for Safe Haskell as now they're safe by defaultDavid Terei2014-11-216-7/+9
|
* Remove redundant "Minimal complete definition"-commentsHerbert Valerio Riedel2014-11-041-1/+1
| | | | | | | | | | | | Those manual descriptions in Haddock strings have become redundant since Haddock gained the ability to print the minimal complete definition as specified via `{-# MINIMAL #-}` annotation (or otherwise inferred by GHC). Moreover, this commit moves all `{-# MINIMAL #-}` annotations in `base` to the start of the respective `class` definitions, as this is more readable and matches more closely the way Haddock renders that information.
* Remove redundant explicit `Prelude` importsHerbert Valerio Riedel2014-10-193-5/+0
| | | | Since they're implied by the lack of `NoImplicitPrelude`
* `M-x delete-trailing-whitespace` & `M-x untabify`Herbert Valerio Riedel2014-09-241-1/+1
| | | | ...several modules in `base` recently touched by me
* Move `mapM` and `sequence` to GHC.Base and break import-cyclesHerbert Valerio Riedel2014-09-211-2/+1
| | | | | | | | | | This simplifies the import graph and more importantly removes import cycles that arise due to `Control.Monad` & `Data.List` importing `Data.Traversable` (preparation for #9586) Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D234
* Export `Traversable()` and `Foldable()` from PreludeHerbert Valerio Riedel2014-09-151-3/+8
| | | | | | | | | | | | | | | | | | | | | | 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-091-1/+5
| | | | | | | | | | | | | | | | | | | | | 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
* Remove obsolete pre-Haddock-2 `#hide` pragmasHerbert Valerio Riedel2013-09-232-2/+0
| | | | | | | | | | | | The now obsolete (and redundant) `#hide` pragmas have been superseded by `{-# OPTIONS_HADDOCK hide #-}` pragmas which are used by most of the affected modules anyway. This commit also adds proper `{-# OPTIONS_HADDOCK hide #-}` pragmas to `GHC.Desugar` and `GHC.IO.Encoding.Iconv` which had only the ineffective `#hide` annotation. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Add `{-# MINIMAL #-}` annotations to typeclassesHerbert Valerio Riedel2013-09-181-0/+1
| | | | | | | | | | | | | | | | | This makes use of the new `{-# MINIMAL #-}` facility (see #7633) for the following typeclasses - `Bits` - `Foldable` - `Fractional` - `Num` - `MonadZip` - `Read` - `Show` - `Storable` - `Traversable` Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Make `<Typeable.h>` obsolete and refactor away its useHerbert Valerio Riedel2013-09-171-3/+0
| | | | | | | | | | | 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-173-28/+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-173-25/+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 some functions deprecated since GHC 7.2.Ian Lynagh2013-03-012-35/+0
|
* Give Control.Monad.Instances a proper DEPRECATED pragmaIan Lynagh2013-02-161-2/+3
|