Re: type errors

1998-07-01 Thread Fergus Henderson
On 01-Jul-1998, Simon L Peyton Jones <[EMAIL PROTECTED]> wrote: > However, on further reflection, I now think: > > in any case where ambiguity would not result > the original class declaration should be re-formulated > > So, I now think that the existing rule (all class variabl

RE: type errors

1998-07-01 Thread Mark P Jones
| >delete :: (Dictionary dict key dat) => key -> dict -> dict | | It would not *always* result in ambiguity. For example, consider | | instance Dictionary (MyDict dat) Int dat where ... | | f :: MyDict dat -> MyDit dat | f d = delete (3::Int) d | | Here, the polymorphism

Re: type errors

1998-07-01 Thread Alastair Reid
Simon PJ wrote: > So, I now think that the existing rule (all class variables > must appear in each class-operation type signature) is probably > the right one, but on stylistic rather than technical grounds. I feel very uneasy about this style of argument - a language designed this way become

Re: type errors

1998-07-01 Thread Simon L Peyton Jones
> | > > class (Eq key, Ord key) => Dictionary dict key dat where > | > > delete :: key -> dict -> dict > | ... > | > the first error: > | > > | > Class type variable `dat' does not appear in method signature > | > delete :: key -> dict -> dict > | > > | > Why does ghc expect tha

Re: type errors

1998-07-01 Thread Ralf Hinze
> Ok, I did not reconize this solution, it seems to me the (nearly) proper one. > But why not write: > >class => Dictionary dict where >delete :: (Eq key, Ord key) => key -> dict key dat -> dict key dat >... > > So one could avoid multiparamter classes at all. The two types k

Re: type errors

1998-07-01 Thread Simon L Peyton Jones
> > Actually I think you would be better off with a class like > > this: > > > > class (Eq key, Ord key) => Dictionary dict key where > > delete :: key -> dict dat -> dict dat > > search :: key -> dict dat -> (key, SearchResult dat, dict dat) > > searchList :: [key] -> dict dat -

Re: type errors

1998-06-30 Thread Martin Stein
> Actually I think you would be better off with a class like > this: > > class (Eq key, Ord key) => Dictionary dict key where > delete :: key -> dict dat -> dict dat > search :: key -> dict dat -> (key, SearchResult dat, dict dat) > searchList :: [key] -> dict dat -> ([(key,Searc

RE: type errors

1998-06-30 Thread Mark P Jones
| > > class (Eq key, Ord key) => Dictionary dict key dat where | > > delete :: key -> dict -> dict | ... | > the first error: | > | > Class type variable `dat' does not appear in method signature | > delete :: key -> dict -> dict | > | > Why does ghc expect that I use all of the

Re: type errors

1998-06-30 Thread Simon L Peyton Jones
> The ghc compiler complains about 2 type errors in the following code: > > > data SearchResult a = Found a | Fail > > > > class (Eq key, Ord key) => Dictionary dict key dat where > > delete :: key -> dict -> dict > > search :: key -> dict -> (key,SearchResult dat,dict) > > searchL

Re: type errors

1998-06-30 Thread Philip Wadler
You're right. The restriction is excessive. Thanks for pointing this out. Probably we should only require that at least one of the class variables is constrained. Why even require this? (All x) => x -> x uses the class `All' which restricts its argument not one whit. -- P