[Haskell-cafe] ContT and ST stack
limestrael at gmail.com
Thu Mar 10 18:24:01 CET 2011
Why has the operator (.) troubles with a type like (forall s. ST s a)?
Why can't it match the type 'b' in (.) definition?
2011/3/10 Daniel Fischer <daniel.is.fischer at googlemail.com>
> On Thursday 10 March 2011 14:18:24, Anakim Border wrote:
> > Dear list,
> > I have the following (simplified) piece of code:
> > find :: Int -> [Int]
> > find i = runST . (`runContT` return) $
> > callCC $ \escape -> do
> > return 
> > which used to compile correctly under GHC 6.12.3.
> > Now that I've switched to 7.0.2 it gets rejected with the following
> > error:
> > Couldn't match expected type `forall s. ST s c0'
> > with actual type `m0 r0'
> > Expected type: ContT r0 m0 a0 -> forall s. ST s c0
> > Actual type: ContT r0 m0 a0 -> m0 r0
> > In the second argument of `(.)', namely `(`runContT` return)'
> > In the expression: runST . (`runContT` return)
> > I'm a little bit lost at what exactly is the problem.
> If memory serves correctly, it's impredicative polymorphism.
> The type of (.), (b -> c) -> (a -> b) -> a -> c, can't handle
> (x -> forall s. ST s [Int])
> Previously there was an implementation of impredicative polymorphism which
> allowed GHC to handle that construct, but that has been removed (because it
> was unsatisfactory), so GHC 7 doesn't compile that anymore.
> > Anyone can suggest a solution?
> find i = runST ((`runContT` return) $
> callCC $ \escape -> do
> return )
> > Thanks!
> > AB
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe