Inferring from context declarations

George Russell
Wed, 21 Feb 2001 16:46:48 +0100

Andreas Rossberg wrote:
> George Russell wrote:
> >
> > I'm sorry if this is a FAQ, but I'm curious to know why Haskell (or at least, GHC and Hugs)
> > doesn't seem able to use contexts on variables at the front of data declarations.
> There has been some discussion on contexts on data declarations during
> the Haskell 98 standardization process. See:
I see that normal mortals, being only users, are not permitted to contribute
to this particular bulletin board.  But I would like to point out that
(1) Even in their current form, contexts in data declaration serve a useful
    purpose, since they provide and enforce a form of documentation.
(2) If the context in a data declaration were made publicly available, it would
    be even more useful, for all the good reasons given.
(3) Simon Peyton Jones' comments about dictionary passing are a red herring,
    since they assume a particular form of compiler.  Various (MLj, MLton)
    ML compilers already inline out all polymorphism. Some C++ compilers/linkers
    do it in a rather crude way as well, for templates.  If you can do it,
    you can forget about dictionary passing.  The other benefits are so great
    (strict types can always be unboxed for one thing) that I strongly suspect
    that in ten years or so, when machines are fast enough, this will be the
    norm for producing production code.
       For the next few years, or when compilation speed is more important than
    run-time speed, or for dynamic code loading, we can expect at least some
    code to remain polymorphic when compiled.  But in all these cases, I don't 
    think the extra cost of dictionary passing to be significant.