Here's an example:
f x = do { "c" ; putStrLn "x"; return () }
Test.hs:3:
Couldn't match `[]' against `IO'
Expected type: [t]
Inferred type: IO ()
In the application `putStrLn "x"'
in a `do' expression pattern binding: putStrLn "x"
I don't see an easy way to improve this. I suppose we could
do some kind of "voting" thing, where we take a majority view about
what the result type constructor of the monad is... but that would
take a bit of work.
Hmm. It's a good point, but I'm inclined to wait until there are more
yells before investing effort here.
Simon
| -----Original Message-----
| From: George Russell [mailto:[EMAIL PROTECTED]]
| Sent: 16 July 2001 15:56
| To: [EMAIL PROTECTED]
| Subject: do's and error messages
|
|
| If you have a type error message at the very start of a "do"
| statement, the result can be rather confusing, because the
| typechecker doesn't "know" that do's are almost always have
| type (IO (something)) and so tries to shoehorn the monad to
| fit the type. This has actually happened to me several
| times; the worst case is when the result is (for example) a
| list, which allows the error to propagate further. Is there
| some way of doing something about this?
|
| _______________________________________________
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users
|
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users