[Haskell-cafe] Re: Cost of Overloading vs. HOFs

John Meacham john at repetae.net
Tue May 8 22:06:55 EDT 2007


On Fri, May 04, 2007 at 07:20:03PM -0700, Conal Elliott wrote:
> [switching to haskell-cafe]
> 
> thanks for the explanation, John.  doesn't the list cases mentioned in the
> definition of (+) below assume whole program, in order to know all Num
> instances?

Yes it does in the current implementation, but the type class
implementation is relatively separate from the rest of jhc, so it could
be modified in various ways.

my current thinking for separate compilation is to allow separate
compilation, but have a special pass  at the end right before linking
that goes through and assigns a unique discriminator to each type, so it
would sort of be a built in extensible data type.

it can actually be done without a special linker by just placing each
descriptor in a special section and using their offset from the
beginning of the section as its unique id.

FWIW, I would _love_ some standard way to create closed classes in
haskell'. it would greatly facilitate this sort of optimization without
resorting to much trickery. My current thinking is something like
allowing 'class closed Foo' in export lists, which exports the class
name except won't let you create new instances for it (via that import).
I know the standard trick using a 'Fail' superclass, but having the
compiler recognize that special case feels very unclean.

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list