Weblog of Kenny

Aug 26, 2005 at 08:08 o\clock

Summary on possible Optimization direction.

by: luzm

1. Laziness
    e.g see XHaskell webpage.
2. Combining dcast and ucast when R_\gamma_i = R_i
    e.g see XHaskell webpage or the following email from Martin



g1 :: (A|B|C|D|E) -> ...

g2 :: (A|B|C|D) -> ...


f :: (A|B|C|D) -> ...
f (x as A) = (g1 x, g2 x)
...

currently, we'd infer/translate (roughly) the following

f :: Or A B C D ->
f v = case (d v) of
Just x -> (g1 (u1 x), g2 (u2 x)

where

d :: Or A B C D -> Maybe A
u1 :: A -> Or A B C D E
u2 :: A -> Or A B C D

We're doing here quite a lot of structural manipulations
to get the underlying types right.

I assume that other approaches (uniform run-time rep)
would be faster here?

I'm wondering how we could optimize the above?
E.g., we could generate

f :: Or A B C D ->
f v = case (d v) of
Just x -> (g1 v, g2 v)

That is, the downcast is simply a test only.
But then, we use the "original" input value v
in the body of the pattern clause.

Other ways to optimize such cases?

Are there other similar siuations where
we doing such (seeminglessly redundant)
transformations?

Are such cases common?


3. Smarter Inference. See thesis proposal.
4. Deforestation. yet to find example.
5. Finding the unique slice among patterns. yet get more evidence.

Log in to comment:

Attention: many blogigo features are only available to registered users. Register now without any obligations and get your free weblog!