[Haskell-cafe] Why do I have to specify (Monad m) here
sebastian.sylvan at gmail.com
Sun Feb 18 17:55:19 EST 2007
On 2/18/07, Dean Herington <heringtonlacey at mindspring.com> wrote:
> At 12:42 AM +0400 2/19/07, David Tolpin wrote:
> >On Mon, 19 Feb 2007 00:30:47 +0400, Sebastian Sylvan
> ><sebastian.sylvan at gmail.com> 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
> >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.
More information about the Haskell-Cafe