On Aug 15, 2014 12:06 AM, "wren romano" <winterkoninkje@gmail.com> wrote:
>
> On Fri, Aug 15, 2014 at 12:05 AM, wren romano <winterkoninkje@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.