From: Ross Paterson Date: Mon, 3 Jan 2011 18:57:22 +0000 (+0000) Subject: Add Applicative instances for ST monads (proposal #4455) X-Git-Url: http://git.megacz.com/?p=ghc-base.git;a=commitdiff_plain;h=6c5da11b55ef71607cf0b8cf408c10cd5f99530c Add Applicative instances for ST monads (proposal #4455) patch from Bas van Dijk --- 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