From 6c5da11b55ef71607cf0b8cf408c10cd5f99530c Mon Sep 17 00:00:00 2001 From: Ross Paterson Date: Mon, 3 Jan 2011 18:57:22 +0000 Subject: [PATCH] Add Applicative instances for ST monads (proposal #4455) patch from Bas van Dijk --- Control/Applicative.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Control/Applicative.hs b/Control/Applicative.hs index 154b591..ab6b365 100644 --- a/Control/Applicative.hs +++ b/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 -- 1.7.10.4