Proposal: add unfoldr1 to the somewhere in base
David Feuer
david.feuer at gmail.com
Fri Aug 15 04:14:23 UTC 2014
On Aug 15, 2014 12:06 AM, "wren romano" <winterkoninkje at gmail.com> wrote:
>
> On Fri, Aug 15, 2014 at 12:05 AM, wren romano <winterkoninkje at gmail.com>
wrote:
> > unfoldr1 :: (b -> (a, Maybe b)) -> b -> [a]
> > unfoldr1 f = unfoldr (fmap f) . Just
> >
> > Note that unless unfoldr is inlined whenever its first argument is
> > supplied, the use of (Maybe b) as the seed type means you'll get a lot
> > more allocation and case analysis than in your direct definition.
Although this seems to work out okay in isolation, it seems to lead to
phase issues where the static constructor analysis (or whatever it's
called) that makes the extra Maybe go away clashes in some timing fashion
with other analyses, preventing some *other* optimizations from working. Or
at least, that's what it looks like. I haven't entirely figured it out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140815/79607e43/attachment.html>
More information about the Libraries
mailing list