[Haskell] Re: IO == ST RealWorld

John Meacham john at repetae.net
Tue Feb 21 19:19:07 EST 2006

On Mon, Feb 20, 2006 at 10:57:23PM +0000, Ben Rudiak-Gould wrote:
> could static analysis then eliminate the test for FailIO in ST code? It 
> would be pretty cool if the answer was yes, since it would mean that 
> merging IO and ST would be an optimization instead of a pessimization (the 
> test could also be omitted in IO code that uses only the ST subset). In jhc 
> I suppose this would have to happen late in compilation, when you eliminate 
> unused type parameters.

Hmm.. not sure, that is an interesting idea, I do do a form of 'early'
type analysis to drop branches for types that are never used, but before
the whole program is collected it is necessarily conservative so can't
find everything. combining that analysis with GADTs might open up some
new optimizations.

> Actually, won't the test for FailIO always be eliminated by the existing 
> points-to analysis?

Yeah, a lot of them are. but that doesn't happen til very late in the
code generation so these FailIOs clutter up the intermediate jhc core
code. I am experimenting with using longjmp(2) and setjmp(2) based
exceptions in IO. though, I'd eventually like to add true c-- style
continuations to grin which should obviate the need for setjmp and
longjmp which currently cannot be optimized through all that well.


John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell mailing list