
Hello Daryoush, Wednesday, May 13, 2009, 6:11:10 AM, you wrote:
runST :: (forall s. ST s a) -> a
evalStateT :: Monad m => StateT s m a -> s -> m a
these are quite opposite things. later means that you should pass some value of Monad class (well, in this case it's StateT value whose type is limited to Monad in second argument) first means that you should pass *polymorphic* value - i.e. value valid for *any* s thta's even more exiting is that evalStateT is example of polymorphic value - it's a function that can process any Monad value but definitely it will be easier to start with simpler examples. let's see: length :: forall a. [a] -> Int it's, like evalStateT, polymorphic function - it can process lists of any type. more specific polymorphic functions may have class constraints: sum :: (forall a. Num a) => [a] -> a that may be reduced down to: sum :: (Num a) => [a] -> a now let's write a function that may accept *any* function with the type as length: rank2_function :: (forall a. [a] -> Int) -> Int -> Int rank2_function f 1 = f "test" rank2_function f 2 = f [1..3] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com