[mercury-users] Document Giving Help with Typeclasses

Ralph Becket rbeck at microsoft.com
Sat Nov 4 04:11:02 AEDT 2000


Hi Tyson, thanks for the feedback.

>From Tyson Dowd on 03/11/2000 03:14:38
> Add something like:
> 
> It is as if there is an explicit `for all [T]' attached to the
> function's type signature. 

I've added this one.
> 
> Note that this is why a value of type T needs to be an input parameter.

But not this one (as David points out, you can have polymorphic outputs
and a complete explanation is probably unnecessary and would detract from
the main point.)

> > Here, new_db/0 generates new database objects on demand.  Each database
has
> > its own, unique type.  When we add records to a database, we obtain keys
> > also tagged with that type.  This means that the compiler can statically
> > check that we don't use keys from one database to try to access records
in
> > another database.
> > 
> > This only works because new_db/0 decides the DB type tag, not its
callers.
> 
> I'm not so sure about this example, because it involves some
> functionality that is under the hood which is reasonably complex.
> Perhaps if the implementation were given this would be good.
> It's not clear what "tagged with that type" and "unique type" mean.
> 
> Explaining that it is the :- some [DB] .... part that makes the
> difference is good.
> 
> It's good to note the relationship with existential type variables and
output
> modes (and to compare with universal type vars and input modes).

I'll do some thinking about this one (Friday afternoon brain failure...)

> > Q. Will life always be like this?
> > 
> > A. Hopefully not.  Constructor classes and, in particular, functional
type
> > dependencies will be integrated into the typeclass mechanism and do away
> > with the need for many of the work-arounds outlined in this document.
> 
> It's worth noting that AFAIK nobody is actually working on this right
> now (e.g. there is nobody planning on implementing this in the next 6-12
> months).  This could change, but I don't know of any plans.

I thought somebody had done some work on constructor classes?  Functional
dependencies, though, are still a pipe dream.  Has anyone got a spare RA
or 1st year PhD student they can coerce into doing the job?

Either way, my motivation for including that Q & A is to underline the fact
that we really need these things.

Cheers,

Ralph

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list