|
Boost : |
Subject: Re: [boost] [Hana] Informal review request
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2015-03-17 13:39:50
Eric Niebler <eniebler <at> boost.org> writes:
>
> On 3/16/2015 4:43 PM, Louis Dionne wrote:
> <snip>
> > However, there is a more serious
> > incompatibility stemming from how `reverse_fold` is usually specified
> > and understood: as starting from the end. This causes a problem for
> > infinite data structures, which obviously have no reachable end. Instead,
> > `foldr` is usually specified recursively in a way that makes it possible
> > to right-fold infinite data structures (and it is indeed possible to do
> > so in Haskell and with MPL11). There is no real support for infinite data
> > structures in Hana right now, but simple Concept generalizations which I
> > have been thinking about might make this possible. In summary$Ý
¹ÐѼ(øøµ
ÍÕÉ$´¹½Ð±½¥¹µåͱ¥$µ
Ñ¡½±°½½±É¡
¹°ÕÐ(øøÉÍÐ
ÍÍÕÉÑ¡
Ð$Õ¹ÉÍѽ½ÙÉäݱ°Ñ¡Á½Á±Ìͥɸ(ø(ø$ÁÉͽ¹
±±ä½¸ÐÍÁɽ±´Ý¥Ñ Á¥¹½±ÈÌ͵
¹Ñ¥ÌÕÐ(ø¡
¹¥¹Ñ¡¹
µÑ¼ÉÙÉÍ}½±°¥Ñ¡
ÐÌÝ¡
ÐÁ½Á±Ý
¹Ð¸()Q¡Áɽ±´¥ÌÑ¡
Ð¥¸Ñ¡¥¹¥¹¥Ñ
Í°¥Ð̹½ÐÉÙÉͽ±
¹åµ½É°)
¹¡¹Ñ¡¹
µ½µÌÙÉ䵥ͱ
¥¹¸½ÈÑ¡½ÍÑ¡
е¥¡ÐÉ
¥¹)Ñ¡¥Ì
¹Ý½¹É¥¹Ý¡
Ð$µ
¸ä¹½¸µÍÑɥн±Ì°¡ÉÌ¡½Ü½±É
¸)¥¹ÉÕÉÍ¥Ù±äè((ѵÁ±
ÑñÑåÁ¹
µMÅÕ¹°ÑåÁ¹
µMÑ
Ñ°ÑåÁ¹
µø(
ÕѼ½±È¡MÅÕ¹áÌ°MÑ
ÑÌ°¤ì(¥¡¥Í}µÁÑä¡á̤¤(ÉÑÕɸÌì(±Í(ÉÑÕɸ¡¡
¡á̤°½±È¡Ñ
¥°¡áÌ2Âb°¢Ð ¤â7G&7BWfÇVFöâ6öçFWBÂvVâFRVÇ6R'&æ62F¶VâÂFRÚ]p¨Ø[ÈÛ\È]\][X]Y\È[ÝÜÂØÙ\ÜÚ[È[[]H\ÝÈ^[H[Ü][ÈÚÜXÚ\ÝZ][È[ÛÜ]\ÈÝXÚ\Â[\]H\[[YHÙ\]Y[ÙK\[[YHYXØ]OÛÛ[WÛÙÙ\]Y[ÙHËYXØ]HY
HÂ]\ÛË[ÙK×J]]È]]ÈJHÂ]\Y
HY
JNÂJNÂB[\XÚ]K[HXÝH^[\KYY
X]\ÈYHÜÛÛYH[HÛÜ\ÜÛ[ÈY
JX\È]\][X]YXØ]\ÙHÚÜXÚ\ÝZ]ËXØ]\ÙHÙIÜH[H\Ý]XØ[Û\ÝXÝ][X][ÛÛÜ\ÈØ]\Ù\ÈXÝÈH][X]Y][ÝÙ]\Y[ÝHÛÈXÚÈÈHY[][ÛÙÛXÝKHXØ\È[^\ÜÚ[ÛÙHÜBÛZ[
ÊKËBÚ\H\ÈÝ\[XH[Hny_of` algorithm. So basically, we're
saying that the recursive call to `foldr` is not evaluated, and hence
our `any_of` algorithm short-circuits automatically.
So anyway, my point is that seeing right-folds as
f(x1, f(x2, f(x3, ...f(xN, state)))
is slightly more general than seeing them as starting from the end,
because it allows for the case where there's no end. That being said,
I'm aware that we're _not_ in Haskell and so it does not really apply
to Hana. I'd just like to make sure that I (or someone else) won't find
a nice application for infinite data structures in Hana that would make
me regret that choice.
But writing this, I have the germ of an idea that these lazy folds
might be nothing more than a monadic fold with the Lazy Monad, whicݽձÉͽ±ÙÑ¡¥ÍÍÕ¸$¡
ÙѼ±½½¬¥¹Ñ¼Ñ¡¥ÌÕÉѡȽÉ$
¸)Í
ä
¹åÑ¡¥¹¸(((øøܸ%¸¥É¹ÐÑ¡É
lÙt°¥ÐÝ
ÌÍÕÍÑÑ¡
ÐÑ¡1½¥
°(øø½¹ÁÐÍ¡½Õ±¥¹ÑÉ
Ðݱ°Ý¥Ñ 1
éä½µÁÕÑ
Ñ¥½¹Ì¸$¡
ÙÕ¸(øøѼ¥¹ÙÍÑ¥
ÑÁ½ÍÍ¥±Ý
å̽¹¥±äÑ她½Ñ ѽѡȰ
Ì
¸(øø͸
ÐlÝt°
¹Ý¥±°ÑÉäѼ¡
ÙͽµÑ¡¥¹¥¹¥Ñ¥Ù½É(øø½Éµ
°É٥ܸ(ø(øølÝt¡ÑÑÀè¼½±¥½¹¹¹¥Ñ¡Õ¹¥¼¼ÈÀÄÔ¼À̼Äؽ±
饹Í̵
̵µ½µ½¹
(ø(øÝͽµ¸$´É
±±ä±½½¥¹½ÉÝ
ÉѼÉ
¥¹Ñ¡¥Ì¸()Ì¥ÐÍÑ
¹Ì°$¥¹Ñ¡Á½ÍÐѼ¥Ð½É¥¹
ÕÍÑ¡ÉÌ)¹¼¥¹ÑÉÍÑ¥¹ÕÍ
Í
ÐÑ¡¹¸$´Ñ¡¥¹¥¹
½ÕÐáÁ
¹¥¹)½¸¡½ÜÝ
¸½µÁ½Í±
éä½µÁÕÑ
Ñ¥½¹Ì¡
ÌÁÁ±¥
Ñ¥ÙÌ
¹5½¹
̤°)Ý¡¥ ¥ÌÉ
±±äÑ¡Õ¸Á
ÉÐ
¹
±FR'BFBvfW2W2&WGG§6VÖçF72f÷"6ö×÷6ær&&G&'Ƨ6ö×WFFöç2âÆö6ÆÇÂfP§&÷F÷GVBæWreövF&÷FƧæBæöâÖƧ6VÖçF72v6Ø[ÈÜ\K[ÛÛ][Û[HÙ[XÝ[ÈHÝXÝ]][ÛÈH]H[Ø]\ÙXÝÜKÛÈ]XÚXYÚXËÛÈYXÝ[ÈÜÚË[ÛÝ[][Ø]\ÙH\ÜÈBØ]\Ú[È[Y\[[Ý[X][ÛÈÙ[ÜÈÝYX[ÈB[Ý[X]YKHÚXÚYX[È[ÜÈYYÈHÝXÝ ÙY]Ë]ËBÛÝ[Y\HÚ[\\[ÜHYXÝXH[ÛÜ]K][]H^[ÙB\ÜÈ]H[X\ËHÛÈYÜYH]T ÜÈ[XH^\ÜÚ[ÛÈ\HÈ[\ÜXÚX[HÂ[\[Y[Ü[KHÛÝ[Z[HÜÛÛY][È]XÚÚ[\\XØ]\ÙB]ÛÝ[\ÝHHØ^HÈ]ZXÚÛHÛÛ\ÜÙH\K[][ÛÛ\]][ÛÈ[Ü\ÈØ]HHÛÝ\HÙ[\ËÜ[ÜHÛÛ\^ÛÛ\]][ÛË^HÜ[[Û\ÈÝ[]ÛHÚÝ[\ÙHZ[[Ý[ÛËYØ\ËÝZ\Â
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk