[Haskell-cafe] Composing functions with runST

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Mon Jan 1 06:35:46 EST 2007

On Jan 1, 2007, at 6:02 , Yitzchak Gale wrote:

> 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'

I think the problem is that technically runST is a data constructor  
(possibly not relevant) which takes a function as a parameter  
(definitely relevant).  In the normal compositional model, (f . g) x  
= f (g x), you're conceptually invoking f on the result of g x (g is  
independent of f); here, you're lifting the function g x into the ST  
s a monad via f (g is dependent on f).

brandon s. allbery    [linux,solaris,freebsd,perl]     allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list