Ralf Hinze wrote:
> | Is this what you meant it to do? We decided that hugs shouldn't silently make this
> | decision for you.
>
> Well, I see the problem. Thanks for pointing this out. BUT, as we know
> I doesn't matter in this particular case which instance Hugs chooses as
> both are the same! So, in giving a completely `generic' instance like
>
> > instance (Monad m) => Functor m where
> > fmap f m = m >>= return . f
>
> I kind of tell the compiler that overlapping instances are guarenteed
> to be identical. This is, of course, a proof obligation for the
> programmer.
One of the things I want the type class system to be is predictable. The old hugs
behavior made it difficult to predict when overlapping would apply and when it
wouldn't.
Let me put that differently - the method by which you told the compiler when not to
allow overlapping was rather indirect. I can't help but notice that you said `I *kind
of* tell the compiler'. Well, I don't want the compiler to have to try to read my mind
- that way lies madness ;-)
Now, I can agree that it would be nice to have some finer grain control over
overlapping
- but I don't think it should be by the omission of a predicate from a signature.
>
>
> | Looking at the signature of wrap again, by omitting `Functor' from the context, you
> | are telling hugs to commit to a particular instance for `Functor'. Previously, it
> | chose the more general instance. Now, it recognizes that it's too early to commit
> | to a choice, because there are also more specific instances of `Functor' around,
> | and it's too early to rule them out.
> |
> | So, the solution is simply to put `Functor m' in the signature for `wrap'.
>
> Oh no! If I have to this then the `generic' instance is completely
> useless! Do you agree? So please provide the old behaviour, as well.
> Otherwise, there is no point in allowing `generic' instances.
Well, no, I don't agree. The generic instance allows the creation of a Functor
instance
from a Monad instance when no more specific functor instance exists. That's useful.
But maybe I'm missing your point?
--Jeff