[Haskell-cafe] asserting the type of a binding in a "do" expression

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sat Apr 26 02:49:32 EDT 2008

On Apr 26, 2008, at 2:36 , Ken Takusagawa wrote:

> But this does not:
>  foo::IO a;
>  foo = do{
>    (x::a) <- bar;
>    return x;};
> Error message: A pattern type signature cannot bind scoped type
> variables `a' unless the pattern has a rigid type context.

This works for me (in a slightly out of date HEAD) if I explicitly  
forall the declaration as per the ghc manual (see section

 > bar :: forall b. IO b
 > bar =  return undefined -- just want a type for now
 > foo :: forall a. IO a
 > foo =  do { (x :: a) <- bar; return x; }

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] 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