projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
extract information about Data.Time from docs for CTime
[ghc-base.git]
/
Control
/
Applicative.hs
diff --git
a/Control/Applicative.hs
b/Control/Applicative.hs
index
8aa86e1
..
154b591
100644
(file)
--- a/
Control/Applicative.hs
+++ b/
Control/Applicative.hs
@@
-36,7
+36,6
@@
module Control.Applicative (
) where
import Prelude hiding (id,(.))
) where
import Prelude hiding (id,(.))
-import qualified Prelude (id)
import Control.Category
import Control.Arrow
import Control.Category
import Control.Arrow
@@
-46,6
+45,10
@@
import Control.Monad.Instances ()
import Data.Functor ((<$>), (<$))
import Data.Monoid (Monoid(..))
import Data.Functor ((<$>), (<$))
import Data.Monoid (Monoid(..))
+#ifdef __GLASGOW_HASKELL__
+import GHC.Conc (STM, retry, orElse)
+#endif
+
infixl 3 <|>
infixl 4 <*>, <*, *>, <**>
infixl 3 <|>
infixl 4 <*>, <*, *>, <**>
@@
-146,6
+149,16
@@
instance Applicative IO where
pure = return
(<*>) = ap
pure = return
(<*>) = ap
+#ifdef __GLASGOW_HASKELL__
+instance Applicative STM where
+ pure = return
+ (<*>) = ap
+
+instance Alternative STM where
+ empty = retry
+ (<|>) = orElse
+#endif
+
instance Applicative ((->) a) where
pure = const
(<*>) f g x = f x (g x)
instance Applicative ((->) a) where
pure = const
(<*>) f g x = f x (g x)
@@
-154,6
+167,11
@@
instance Monoid a => Applicative ((,) a) where
pure x = (mempty, x)
(u, f) <*> (v, x) = (u `mappend` v, f x)
pure x = (mempty, x)
(u, f) <*> (v, x) = (u `mappend` v, f x)
+instance Applicative (Either e) where
+ pure = Right
+ Left e <*> _ = Left e
+ Right f <*> r = fmap f r
+
-- new instances
newtype Const a b = Const { getConst :: a }
-- new instances
newtype Const a b = Const { getConst :: a }