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

Ken Takusagawa ken.takusagawa.2 at gmail.com
Sat Apr 26 02:36:43 EDT 2008


This works (with -fglasgow-exts):

 foo::IO Int;
 foo = do{
   (x::Int) <- bar;
   return x;};

 bar = undefined

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.

How can I accomplish my goal of asserting the type of x, as a
programmer sanity check, when there are type variables?

Thanks,

--ken


More information about the Haskell-Cafe mailing list