Proposal: Add chop function to Data.List
ekmett at gmail.com
Wed Feb 9 02:32:33 CET 2011
+1 for the inclusion of chop.
The unfoldr relationship is a good thing, because it gives an insight into
when you can do 'chop fusion' by leaning on the unfoldr/destroy rules. ;)
If we actually used unfoldr/destroy fusion, I'd probably advocate for
defining chop in terms of unfoldr as a consequence, to facilitate rewriting,
but noting the relationship at least provides a nice way to handle it for
the stream fusion folks.
On Tue, Dec 14, 2010 at 10:38 AM, Lennart Augustsson <lennart at augustsson.net
> Yes, chop can be easily written in terms of unfoldr. But the chop function
> fits better with other existing list functions, like I tried to illustrate
> with my examples.
> -- Lennart
> On Tue, Dec 14, 2010 at 10:40 AM, Stefan Holdermans <
> stefan at vectorfabrics.com> wrote:
>> >> I would like to propose the following function for inclusion in
>> >> chop :: (a -> (b, [a]) -> [a] -> [b]
>> >> chop _  = 
>> >> chop f as = b : chop f as'
>> >> where (b, as') = f as
>> > Is the difference between 'unfoldr' and 'chop' just the Maybe result
>> type of f?
>> chop f = unfoldr g
>> g  = Nothing
>> g as = Just (f as)
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries