Re: Re[2]: [Haskell-cafe] Why do I have to specify (Monad m) here again?

On 2/18/07, Dean Herington
At 12:42 AM +0400 2/19/07, David Tolpin wrote:
On Mon, 19 Feb 2007 00:30:47 +0400, Sebastian Sylvan
wrote: Well, I guess the H98 report would be a good start. But there are multiple tutorials on type classes that will cover this, most of which are available from haskell.org
Sebastian,
I did read H98 and would like an exact reference.
See section 4.3.2, the third bullet item in the bulleted list. (Note that the last sentence of that bullet item says that context inference--though often possible--is deliberately eschewed.)
Yes, but the key point still stands: when the user supplies a type, is should get taken seriously. Just because there may be a way to infer a context which may work in some/most cases, doesn't mean it's a good idea to do so because in all other parts of Haskell the user supplied type is taken seriously -- if you don't include a context, that means there *is* no context. Period. In the original example you really are telling Haskell that you *don't* want any context for "m". So if you want some inference to happen there, you need to find a way to specify that you want "any" contexts rather than no contexts. E.g. instance ( _ m) => GetMV m c where I don't think there's another way to do what you want without seriously messing Haskell up. -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862
participants (1)
-
Sebastian Sylvan