From: Bas van Dijk Date: Sun, 16 May 2010 17:17:56 +0000 (+0000) Subject: Added Applicative and Alternative instances for STM X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=87d1ac62b8114727d8756a4c239992bff6c854ea;p=ghc-base.git Added Applicative and Alternative instances for STM --- diff --git a/Control/Applicative.hs b/Control/Applicative.hs index e60182d..a2755eb 100644 --- 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)