Type class instances in scope

Edward Z. Yang ezyang at mit.edu
Fri May 19 12:35:32 UTC 2017


Excerpts from Tom Sydney Kerckhove's message of 2017-05-19 11:05:17 +0200:
> Oh, that's annoying.
> I have a feeling there is room for an optimisation here.
> ... or maybe this was already an optimisation, I don't really know.

It's an optimization. Without, we would have to eagerly load every
interface you transitively import, even if you didn't end up using them.
That would be really slow.

> > I'm not sure exactly what you are actually trying to do.
> 
> More concretely, I need to generate a line of code for every 'Arbitrary'
> instance in scope.
> 
> Later I'll also need to use other instances but this is the first part.

OK...

> > But if you
> > really need all instances, you will have to first arrange to load
> > the interfaces of ALL modules transitively imported by your module.
> 
> I don't really mind the time it takes to do this, but that's annoying to
> write.
> 
> Thank you for your help! I will look into it.

Another possibility is, if you can programatically list the types that
you are interested in, you can load all of those, and then the instances
for those types will be ready.


More information about the ghc-devs mailing list