summaryrefslogtreecommitdiff
path: root/libraries/base
diff options
context:
space:
mode:
authorRoss Paterson <ross@soi.city.ac.uk>2011-01-03 18:57:22 +0000
committerRoss Paterson <ross@soi.city.ac.uk>2011-01-03 18:57:22 +0000
commit85bbbc42e8a37edbc50b6d4063bd5818b4c50d5e (patch)
treef28ebc2a7d466851ba967f6e2a61d8897c56ce6f /libraries/base
parent798805f7e841f381469a0c1d750970575d8e6fda (diff)
downloadhaskell-85bbbc42e8a37edbc50b6d4063bd5818b4c50d5e.tar.gz
Add Applicative instances for ST monads (proposal #4455)
patch from Bas van Dijk
Diffstat (limited to 'libraries/base')
-rw-r--r--libraries/base/Control/Applicative.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs
index 154b591288..ab6b365cce 100644
--- a/libraries/base/Control/Applicative.hs
+++ b/libraries/base/Control/Applicative.hs
@@ -42,6 +42,8 @@ import Control.Arrow
(Arrow(arr, (&&&)), ArrowZero(zeroArrow), ArrowPlus((<+>)))
import Control.Monad (liftM, ap, MonadPlus(..))
import Control.Monad.Instances ()
+import Control.Monad.ST (ST)
+import qualified Control.Monad.ST.Lazy as Lazy (ST)
import Data.Functor ((<$>), (<$))
import Data.Monoid (Monoid(..))
@@ -149,6 +151,14 @@ instance Applicative IO where
pure = return
(<*>) = ap
+instance Applicative (ST s) where
+ pure = return
+ (<*>) = ap
+
+instance Applicative (Lazy.ST s) where
+ pure = return
+ (<*>) = ap
+
#ifdef __GLASGOW_HASKELL__
instance Applicative STM where
pure = return