[Haskell-cafe] Composing functions with runST

Yitzchak Gale gale at sefer.org
Mon Jan 1 07:48:03 EST 2007


I wrote:
>> Prelude Control.Monad.ST> runST (return 42)
>> 42
>> Prelude Control.Monad.ST> (runST . return) 42
>>
>> <interactive>:1:9:
>>    Couldn't match expected type `forall s. ST s a'
>>           against inferred type `m a1'

Brian Hulley wrote:
> Hazarding a guess, I suggest it *might* be due to the fact that
>
>     forall s. ST s a
>
> means
>
>     forall s. (ST s a)
>
> whereas you'd need it to mean
>
>     (forall s. ST s) a
>
> in order for it to unify with (m a).

But then why does "return 42" type successfully as
forall s. (ST s a)? It needs that same unification.

-Yitz


More information about the Haskell-Cafe mailing list