summaryrefslogtreecommitdiff
path: root/libraries/base/Control/Applicative.hs
Commit message (Collapse)AuthorAgeFilesLines
* Doc-only fixesAlec Theriault2018-11-221-2/+2
| | | | | | * laws are capitalized definition lists, no emphasis on the labels * adds missing hyperlinks * fixes other misc. Haddock markup issues.
* Add @since annotations for derived instances in baseChaitanya Koparkar2018-03-021-4/+16
| | | | | | | | | | | | | | Test Plan: ./validate Reviewers: hvr, goldfire, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: rwbarton, thomie, carter GHC Trac Issues: #11767 Differential Revision: https://phabricator.haskell.org/D4452
* Add forgotten > in Control.ApplicativeOleg Grenrus2017-08-061-1/+1
| | | As reported by tabaqui on `#hackage`
* Add Alternative instance for ZipList (fix #13520).Edvard Hübinette2017-04-041-1/+6
| | | | | | | | | | Reviewers: austin, hvr, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: adamse, RyanGlScott, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3416
* Elaborate further on ZipList Applicative docsChris Martin2017-03-131-5/+13
| | | | | | | | | | | | | | | | | | | | | I was initially confused when I read "zipWithn" in the haddock for ZipList, went looking for a function named "zipWithn", and found that it didn't exist. This expands the docs to clarify that we're referring to the family of functions [zipWith, zipWith3, zipWith4, ...], capitalizes the letter "n" in "zipWithN" in attempt to make that more readable, and gives an example. I also moved this documentation from ZipList itself to the Applicative instance, so that it will show up in both the Ziplist documentation and in the list of Applicative instances. Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3324
* add example documentation for tuple ApplicativeGinBaby2017-03-061-1/+1
| | | | | | | | | | Reviewers: austin, hvr, bgamari, dfeuer Reviewed By: dfeuer Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D3284
* Add liftA2 to Applicative classDavid Feuer2017-02-051-3/+5
| | | | | | | | | | | | | | | | * 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
* Add @since annotations to base instancesSeraphime Kirkovski2016-06-061-0/+7
| | | | | | | | | | | | | | | | | | 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
* Move Const to own module in Data.Functor.Const and enable PolyKindsShane O'Brien2015-12-211-29/+3
| | | | | | | | | | | | | | | `Const` from `Control.Applicative` can trivially be made kind-polymorphic in its second argument. There has been a Trac issue about this for nearly a year now. It doesn't look like anybody objects to it, so I figured I might as well make a patch. Trac Issues: #10039, #10865, #11135 Differential Revision: https://phabricator.haskell.org/D1630 Reviewers: ekmett, hvr, bgamari Subscribers: RyanGlScott, thomie
* base: MRP-refactoring of AMP instancesHerbert Valerio Riedel2015-10-121-1/+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
* base: Add missing Traversable instance for ZipListBen Gamari2015-08-071-2/+3
|
* base: Add instancesfumieval2015-08-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds following instances: * Foldable ZipList * Traversable ZipList * Functor Complex * Applicative Complex * Monad Complex * Foldable Complex * Traversable Complex * Generic1 Complex * Monoid a => Monoid (Identity a) * Storable () Reviewers: ekmett, fumieval, hvr, austin Subscribers: thomie, #core_libraries_committee Projects: #core_libraries_committee Differential Revision: https://phabricator.haskell.org/D1049 GHC Trac Issues: #10609
* base: drop redundant Typeable derivingsHerbert Valerio Riedel2015-03-071-1/+0
| | | | | | | | | | | 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
* Add Eq, Ord, Show, and Read instances for ConstFumiaki Kinoshita2015-01-141-3/+11
| | | | | | | | | | | | | | | | | | | | | | As suggested in https://www.haskell.org/pipermail/libraries/2013-October/021531.html this adds the following instances - `Show a => Show (Const a b)` - `Read a => Read (Const a b)` - `Eq a => Eq (Const a b)` - `Ord a => Ord (Const a b)` The Read/Show instances are defined in such a way as if `Const` was defined without record-syntax (i.e. as `newtype Const a b = Const a`) Addresses #9984 Reviewed By: ekmett Differential Revision: https://phabricator.haskell.org/D619
* Be consistent with placement of Safe Haskell mode at top of fileDavid Terei2014-11-211-1/+1
|
* Use (.) and id from Base in Control.ApplicativeDavid Feuer2014-11-081-2/+2
| | | | | | | | | Control.Applicative previously imported `(.)` and `id` from `Control.Arrow`, but then only applied them to functions. Reviewed By: ekmett, hvr Differential Revision: https://phabricator.haskell.org/D462
* Improve Applicative definitionsDavid Feuer2014-11-071-17/+11
| | | | | | | | | | | | | | | | | | | | | Generally clean up things relating to Applicative and Monad in `GHC.Base` and `Control.Applicative` to make `Applicative` feel like a bit more of a first-class citizen rather than just playing second fiddle to `Monad`. Use `coerce` and GND to improve performance and clarity. Change the default definition of `(*>)` to use `(<$)`, in case the `Functor` instance optimizes that. Moreover, some manually written instances are made into compiler-derived instances. Finally, this also adds a few AMP-related laws to the `Applicative` docstring. NOTE: These changes result in a 13% decrease in allocation for T9020 Reviewed By: ekmett, hvr Differential Revision: https://phabricator.haskell.org/D432
* Invert module-dep between Control.Monad and Data.FoldableHerbert Valerio Riedel2014-09-181-0/+4
| | | | | | | | | This is the last preparation needed before generalizing entities in Control.Monad conflicting with those from Data.Foldable (re #9586) Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D225
* Move Applicative/MonadPlus into GHC.BaseHerbert Valerio Riedel2014-09-181-6/+3
| | | | | | | | | | | This is necessary in order to invert the import-dependency between Data.Foldable and Control.Monad (for addressing #9586) This also updates the `binary` submodule to qualify a GHC.Base import Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D223
* Export `Traversable()` and `Foldable()` from PreludeHerbert Valerio Riedel2014-09-151-5/+12
| | | | | | | | | | | | | | | | | | | | | | 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-211/+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 Functor, Applicative, Monad instances for First, LastBen Gamari2014-07-281-1/+10
| | | | | | | | | | | | | | | | | | | Summary: This was proposed in 2011 [1] with no serious objections although wasn't implemented until it was again mentioned in 2014 [2]. [1] http://www.haskell.org/pipermail/libraries/2011-January/015552.html [2] http://www.haskell.org/pipermail/libraries/2014-June/023228.html Test Plan: None Reviewers: austin Reviewed By: austin Subscribers: hvr, phaskell, simonmar, relrod, carter, ekmett Differential Revision: https://phabricator.haskell.org/D81
* Add some instances for Monoid/Applicative (#8797)Austin Seipp2014-02-281-1/+8
| | | | | | | | | | | | | | | | | | | As noted in the ticket, there's no particular reason why there aren't Generic, Typeable, and Data instances for the types in the Monoid/Applicative modules. Furthermore, Product and Sum should also have Num instances as well as Edward noted. Aside from that, this patch also changes the dependency chain slightly - it moves the Monoid Proxy instance into Data.Monoid and out of Data.Proxy. Why? Cycles (of course). Monoid depends on Typeable. Typeable uses Proxy. Proxy uses Monoid. Boom. Luckily, Proxy only depends on Monoid outside of the GHC namespace, so the fix is easy and clean. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Tweak Haddock markup in Control.ApplicativeHerbert Valerio Riedel2014-02-211-13/+18
| | | | | | This (arguably) improves rendering with Haddock 2.14 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Add `instance Monoid a => Monoid (Const a b)`Herbert Valerio Riedel2013-10-051-0/+5
| | | | | | | | For more details, see original proposal at http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/20369 Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
* Add instance Monad (WrappedMonad m) to Control.Applicative (#8218)Krzysztof Gogolewski2013-09-231-0/+5
|
* Constant-fold `__GLASGOW_HASKELL__` CPP conditionalsHerbert Valerio Riedel2013-09-171-5/+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>
* Eliminate Equality.hs-boot and Proxy.hs-boot by moving instancesRichard Eisenberg2013-07-251-0/+7
|
* Derive Show, Eq, Ord, Read for Control.Applicative.ZipList; fixes #5787Ian Lynagh2013-07-071-1/+1
| | | | Patch from merijn.
* Remove nhc98-specific files and contentIan Lynagh2013-02-151-12/+1
|
* Added missing Functor, Applicative, Alternative and MonadPlus instances ↵Bas van Dijk2012-01-241-1/+35
| | | | Added Applicative and Alternative instances for ReadP and ReadPrec Added Functor, Applicative, Alternative and MonadPlust instances for ArrowMonadx
* Use sharing in the Alternative instance of MaybeBas van Dijk2012-01-141-2/+2
|
* Moved the instances from Control.Monad.Instances to GHC.Base and Data.EitherBas van Dijk2012-01-131-1/+0
|
* SafeHaskell: Added SafeHaskell to baseDavid Terei2011-06-181-2/+3
|
* improve discussion of the laws (doc comments only)Ross Paterson2011-02-281-19/+34
| | | | following a suggestion of Russell O'Connor on the libraries list.
* Use explicit language extensions & remove extension fields from base.cabalsimonpj@microsoft.com2011-01-281-0/+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.
* Instances for ST not available in nhc98.Malcolm.Wallace@me.com2011-01-041-0/+4
|
* indentation tweaks (whitespace only)Ross Paterson2011-01-031-77/+78
|
* Add Applicative instances for ST monads (proposal #4455)Ross Paterson2011-01-031-0/+10
| | | | patch from Bas van Dijk
* add Applicative instance for Either (proposal #4095)Ross Paterson2010-06-171-0/+5
| | | | | This is not the only possible instance for Either, but this one is compatible with the usual Monad instance.
* Added Applicative and Alternative instances for STMBas van Dijk2010-05-161-0/+14
|
* Roll back "Another instance of nhc98's strange import semantics."Ian Lynagh2009-10-091-1/+0
| | | | | | Fri Oct 9 14:50:51 BST 2009 Malcolm.Wallace@cs.york.ac.uk GHC (correctly) warns about the unused import, which breaks the validate build.
* Another instance of nhc98's strange import semantics.Malcolm.Wallace@cs.york.ac.uk2009-10-091-0/+1
|
* make some Applicative functions into methods, and split off Data.Functor ↵Ross Paterson2009-09-151-31/+39
| | | | | | | | | | | | | | | | | | | | | | (proposal #3335) The following functions (<$) :: Functor f => a -> f b -> f a (*>) :: Applicative f => f a -> f b -> f b (<*) :: Applicative f => f a -> f b -> f a some :: Alternative f => f a -> f [a] many :: Alternative f => f a -> f [a] are moved into the corresponding classes, with the existing implementations as default definitions. This gives people creating instances the option of defining specialized implementations of these functions, though they should be equivalent to the default definitions. Although (<$) is now a method of the Functor class, it is hidden in the re-export by the Prelude, Control.Monad and Monad. The new module Data.Functor exposes the full class, plus the function (<$>). These are also re-exported by Control.Applicative.
* Remove unused imports from basesimonpj@microsoft.com2009-07-061-1/+0
| | | | | These unused imports are detected by the new unused-import code
* record libraries@haskell.org as maintainerRoss Paterson2008-04-251-1/+1
|
* untabifyDon Stewart2008-03-081-57/+57
|
* fix nhc98 build: need a qualified Prelude importMalcolm.Wallace@cs.york.ac.uk2007-10-301-0/+1
|
* new Control.Category, ghc ticket #1773Ashley Yakeley2007-10-291-4/+2
|
* new Control.Compositor moduleAshley Yakeley2007-10-131-1/+2
| | | | The Compositor class is a superclass of Arrow.