On 04/05/12 09:08, Magicloud Magiclouds wrote:
Hi,
   Assuming this:
run :: Monad IO a ->  IO a
data Test = Test { f }

   Here I'd like to set f to run, like "Test run". Then what is the type of f?
   The confusing (me) part is that, the argument pass to f is not fixed
on return type, like "f1 :: Monad IO ()", "f2 :: Monad IO Int". So
"data Test a = Test { f :: Monad IO a ->  IO a} does not work.

You need to explicitly add "forall a." to the type of f. For example:

    {-# LANGUAGE PolymorphicComponents #-}
    run :: MonadIO m => m a -> IO a
    newtype Test = Test { f :: forall m a. MonadIO m a => m a -> IO a }



Twan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to