Fundeps and quantified constructors

anatoli anatoli@yahoo.com
Wed, 7 Feb 2001 01:32:38 -0800 (PST)


Hi everybody:

I think I've found what's the problem. Still no solution in sight :(

The problem has nothing to do with fundeps. Consider an example:

> data Foo a = (Eq a) => MkFoo a

This gives the same error message: type variable a is not locally
bound. Apparently, 'a' in 'Eq a' hides 'a' in 'Foo a' instead of
using it. The same error message is given for

> data Foo a = (Eq b) => MkFoo b

I don't know whether this is intended behaviour; IMHO
it should be treated identically to

> data Foo a = MkFoo (Eq a => a)

Hugs accepts either

> data Eq a => Foo a = MkFoo a

or

> data Eq a = MkFoo (Eq a => a)

with no problem, but neither syntax works with Collection:
the first one would look like

> data forall c. Collection c e => AnyColl e = MkColl c

which is a syntax error, and the second one

> data AnyColl e = forall c . MkCall (Collection c e => c)
or alternatively
> data AnyColl e = MkCall (forall c . Collection c e => c)

gives me 'Ambiguous type signature in type component' error.

{ 
  Apparently Hugs is still buggy in the fundep/multiparameter
  classes area; I have an example where Hugs assigns garbage types
  to things when fundeps are involved. This is probably a
  hugs-bugs  issue. 
}

Now to the question:

--- Tom Pledger <Tom.Pledger@peace.com> wrote:
> Does it introduce any new implementation issues?  When a constructor
> like MakeSomeCollection is applied, some implementations gather a
> dictionary of methods appropriate for use with the existentially
> quantified type, right?

I believe that in the general case all implementation must do so, in one
form or another.

> Is that more difficult when it involves a
> non-locally bound type variable?  Even when that type variable is
> constrained by a fundep?

I believe there should be no implementation problems.  In order to gather the 
dictionary, an implementation must know the type of the argument to 
MakeSomeCollection. When this type (say T) is known, the compiler just finds
'instance Collection T whatever' declaration. There can be only one such
instance (because of the fundep). All needed methods are specified there.

Regards
--
anatoli

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/