On May 19, 2009 22:17:39 Tyson Whitehead wrote:
> 2- specialize count for step = iter
>
>  <snip>
>
> 3- specializing iter for next = count
>
>  <snip>
>

I changed this just before sending it and managed to goof step two and three 
(the specializations).  The whole thing, with the correct steps two and three 
should have been the following

1- avoid forming the (iter xs) and (count i+1) closures by passing the 
function and the arguments instead of the function bound to the argument

  iter []     next i done = done
  iter (x:xs) next i done = next i x iter xs

  count i x step xs = step xs count (i+1) (i+1)

  test xs = iter xs count 0 0

2- specialize iter for next = count

  iter  []     next i done = done
  iter  (x:xs) next i done = next  i x iter xs
  iter' []          i done = done
  iter' (x:xs)      i done = count i x iter xs

  count i x step xs = step xs count (i+1) (i+1)

  test xs = iter' xs 0 0

3- specialize count for step = iter (and use the specialized iter')

  iter  []     next i done = done
  iter  (x:xs) next i done = next i x iter xs
  iter' []          i done = done
  iter' (x:xs)      i done = count' i x xs

  count  i x step xs = step  xs count (i+1) (i+1)
  count' i x      xs = iter' xs       (i+1) (i+1)

  test xs = iter' xs 0 0

(iter and count are no longer used and can be dropped at this point)

4- inline count'

  iter' []     i done = done
  iter' (x:xs) i done = iter' xs (i+1) (i+1)

  count' i x xs = iter' xs (i+1) (i+1)

  test xs = iter' xs 0 0

(count is no longer used and can be dropped at this point)

5- eliminate the done argument as it is always the same as the i argument

  iter'' []     i = i
  iter'' (x:xs) i = iter'' xs (i+1)

  test xs = iter'' xs 0

As the first one does not seem to be being performed, I did it manually to see 
if that would be enough that GHC would pickup on the rest.  It seems that this 
isn't the case.  The second two are not being done as well.

Cheers!  -Tyson

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to