Can someone explain to me why the following doesn't work?
foo :: Int -> ST s Int
foo = return
bar :: (forall s. ST s Int) -> Int
bar = runST
baz :: Int -> Int
baz = bar . foo
Error thrown for `baz:
Couldn't match type `ST s0 Int' with `forall s. ST s Int'
Expected type: Int -> forall s. ST s Int
Actual type: Int -> ST s0 Int
I assumed that since bar
can accept any s
in its argument, the result of foo
(which is a particular s
) should be okay.
EDIT: Forgot to add. This works as expected:
quux :: Int -> Int
quux x = bar $ foo x