From 5a5d1ff67cdefaf6a467a7cb5f754e97dd40ecc3 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 23 Nov 2009 22:35:44 +0000 Subject: [PATCH] De-orphan the MonadFix ST instance for GHC --- Control/Monad/Fix.hs | 9 +++++++++ Control/Monad/ST.hs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Control/Monad/Fix.hs b/Control/Monad/Fix.hs index c1b4fe1..57308bf 100644 --- a/Control/Monad/Fix.hs +++ b/Control/Monad/Fix.hs @@ -29,6 +29,9 @@ import Data.Function (fix) #ifdef __HUGS__ import Hugs.Prelude (MonadFix(mfix)) #endif +#if defined(__GLASGOW_HASKELL__) +import GHC.ST +#endif #ifndef __HUGS__ -- | Monads having fixed points with a \'knot-tying\' semantics. @@ -77,3 +80,9 @@ instance MonadFix IO where instance MonadFix ((->) r) where mfix f = \ r -> let a = f a r in a + +#if defined(__GLASGOW_HASKELL__) +instance MonadFix (ST s) where + mfix = fixST +#endif + diff --git a/Control/Monad/ST.hs b/Control/Monad/ST.hs index 3ce5001..8ebb750 100644 --- a/Control/Monad/ST.hs +++ b/Control/Monad/ST.hs @@ -1,4 +1,3 @@ -{-# OPTIONS_GHC -fno-warn-orphans #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.ST @@ -32,7 +31,11 @@ module Control.Monad.ST unsafeSTToIO -- :: ST s a -> IO a ) where +#if defined(__GLASGOW_HASKELL__) +import Control.Monad.Fix () +#else import Control.Monad.Fix +#endif #include "Typeable.h" @@ -58,6 +61,8 @@ unsafeInterleaveST = LazyST.lazyToStrictST . LazyST.unsafeInterleaveST . LazyST.strictToLazyST #endif +#if !defined(__GLASGOW_HASKELL__) instance MonadFix (ST s) where mfix = fixST +#endif -- 1.7.10.4