Hello!
I'm sure you're aware of the close connection between your FR
stuff (nice) and the foldr/build list-fusion work?
I am now. Indeed, the 'FR' representation of lists is what one passes
to 'build'. Incidentally, the higher-rank type of FR is a
_requirement_ (otherwise, things won't type)
Oleg: I'm sure you're aware of the close connection between your FR
stuff (nice) and the foldr/build list-fusion work? (So-called
short-cut deforestation.) To make short-cut deforestation work, one
has to write map, filter etc in precisely the style you give.
I have not grokked your zip idea,
On Tue, Oct 11, 2005 at 05:25:24PM -0700, [EMAIL PROTECTED] wrote:
First we define the representation of a list as a fold:
newtype FR a = FR (forall ans. (a - ans - ans) - ans - ans)
unFR (FR x) = x
It has a rank-2 type. The defining equations are: if flst is a value
of a type |FR a|,
Dylan Thurston wrote:
The defining equations are: if flst is a value
of a type |FR a|, then
unFR flst f z = z if flst represents an empty list
unFR flst f z = f e (unFR flst' f z)
if flst represents the list with the head 'e'
and flst'
We show how to merge two folds into another fold
`elementwise'. Furthermore, we present a library of (potentially
infinite) ``lists'' represented as folds (aka streams, aka
success-failure-continuation--based generators). Whereas the standard
Prelude functions such as |map| and |take| transform