projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1906fa0
)
Added Applicative and Alternative instances for STM
author
Bas van Dijk
<v.dijk.bas@gmail.com>
Sun, 16 May 2010 17:17:56 +0000
(17:17 +0000)
committer
Bas van Dijk
<v.dijk.bas@gmail.com>
Sun, 16 May 2010 17:17:56 +0000
(17:17 +0000)
Control/Applicative.hs
patch
|
blob
|
history
diff --git
a/Control/Applicative.hs
b/Control/Applicative.hs
index
e60182d
..
a2755eb
100644
(file)
--- a/
Control/Applicative.hs
+++ b/
Control/Applicative.hs
@@
-45,6
+45,10
@@
import Control.Monad.Instances ()
import Data.Functor ((<$>), (<$))
import Data.Monoid (Monoid(..))
+#ifdef __GLASGOW_HASKELL__
+import GHC.Conc (STM, retry, orElse)
+#endif
+
infixl 3 <|>
infixl 4 <*>, <*, *>, <**>
@@
-145,6
+149,16
@@
instance Applicative IO where
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)