one more problem with Hugs
Hello , The following code compiles with GHC but not with Hugs. moreover, if you replace STURef with STRef in instance definition, all will be fine. bug? {-# OPTIONS_GHC -cpp -fglasgow-exts #-} import Control.Monad.ST import Data.STRef -- ----------------------------------------------------------------------------- -- Unboxed references in ST monad type STURef = STRef -- | Create new unboxed reference in ST monad newSTURef :: e -> ST s (STURef s e) newSTURef = newSTRef -- ----------------------------------------------------------------------------- -- Monad-neutral interface for fast unboxed references class (Monad m) => URef m r | m->r, r->m where newURef :: a -> m (r a) instance URef (ST s) (STURef s) where newURef = newSTURef -- ----------------------------------------------------------------------------- -- Main test = runST ( do newURef (0::Int) return '1' ) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
Hello Bulat, Tuesday, March 7, 2006, 2:57:47 PM, you wrote: BZ> The following code compiles with GHC but not with Hugs. moreover, if BZ> you replace STURef with STRef in instance definition, all will be BZ> fine. bug? i found the answer himself. Hugs just can't properly understand kind of STURef in this case. "type STURef = STRef" should be changed to "type STURef s a = STRef s a". btw, there was also another cases where Hugs can't determine kind of identifier from such "partial type declarations" ... after checking my solution: Hugs also don't allow to use type synonym here, so i should change this declaration to "newtype STURef s a = STURef (STRef s a)". at least this work.... BZ> {-# OPTIONS_GHC -cpp -fglasgow-exts #-} BZ> import Control.Monad.ST BZ> import Data.STRef BZ> -- BZ> ----------------------------------------------------------------------------- BZ> -- Unboxed references in ST monad BZ> type STURef = STRef BZ> -- | Create new unboxed reference in ST monad BZ> newSTURef :: e -> ST s (STURef s e) BZ> newSTURef = newSTRef BZ> -- BZ> ----------------------------------------------------------------------------- BZ> -- Monad-neutral interface for fast unboxed references BZ> class (Monad m) => URef m r | m->r, r->m where BZ> newURef :: a -> m (r a) BZ> instance URef (ST s) (STURef s) where BZ> newURef = newSTURef BZ> -- BZ> ----------------------------------------------------------------------------- BZ> -- Main BZ> test = runST ( do newURef (0::Int) BZ> return '1' BZ> ) BZ> -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (1)
-
Bulat Ziganshin