[<<][haskell][>>][..]
Thu Aug 2 20:32:30 EDT 2018

runST and rank-2 inference

This doesn't infer properly:

runST' f = runST f

The reason is that 'f' is not inferred as rank-2.
An explicit signature fixes it:

runST' :: (forall s. ST s a) -> a 


Ok I got this far:

-- Derive the correct form by adding stuff to runST.
seqRun' :: ([Int] -> forall s. ST s [Int]) -> [[Int]] -> [[Int]]
seqRun' f i = [runST $ f (head i)]


OK... the error I run into is this:

seqRun' :: ((m,r,[Int]) -> forall s. ST s (m, r, [Int]), (m, r)) ->  [[Int]] -> [[Int]]

SeqPrim.hs:93:12: error:
    • Illegal polymorphic type: forall s. ST s (m, r, [Int])
      GHC doesn't yet support impredicative polymorphism
    • In the type signature:
        seqRun' :: ((m, r, [Int]) -> forall s. ST s (m, r, [Int]), (m, r))
                   -> [[Int]] -> [[Int]]



If I curry this, it's ok:

seqRun' :: ((m,r,[Int]) -> forall s. ST s (m, r, [Int])) -> (m, r) ->  [[Int]] -> [[Int]]



So I was driven into some other corner of the type system.
Why are these not equivalent?

This is quite hard to work around.





[Reply][About]
[<<][haskell][>>][..]