[Haskell-cafe] ContT and ST stack
Yves Parès
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?
>
> Parentheses.
>
> find i = runST ((`runContT` return) $
> callCC $ \escape -> do
> return [])
>
> >
> > Thanks!
> >
> > AB
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110310/41bd8598/attachment.htm>
More information about the Haskell-Cafe
mailing list