fix for Data.List.sortBy

David Feuer david.feuer at gmail.com
Wed Mar 29 03:18:37 UTC 2017


You don't need to use the usual NonEmpty type. You can copy it here.

data NonEmpty a = a :< [a]
data ListNELists a = Cons {-# UNPACK #-} !(NonEmpty a) (ListNELists a) | Nil

Or we could unpack it manually:

data ListNELists a = Cons a [a] (ListNELists a) | Nil

I can't say whether these will make a difference. I'm sorry that I haven't
had the time to really dig into this issue as much as I might; I've been
tied up with other things.


David

On Tue, Mar 28, 2017 at 10:53 PM, Siddhanathan Shanmugam <
siddhanathan+eml at gmail.com> wrote:

>
>
> On Tue, Mar 28, 2017 at 12:48 PM, David Feuer <david.feuer at gmail.com>
> wrote:
>
>> There are a number of intermediate lists that are certainly non-empty,
>> but their types don't reflect that. I wonder if using a non-empty list type
>> unpacked into the list of lists might be helpful.
>>
>
> I just tried it. Seems to work fine, and the benchmark numbers are similar.
>
> Doing this in base would introduce cyclic dependencies though.
>
>
>
>
>>
>> On Mar 28, 2017 3:39 PM, "Gregory Popovitch" <greg7mdp at gmail.com> wrote:
>>
>>> OK, here is the current proposed change - tests look good:
>>>
>>>
>>> Any comments/opposition from the community?
>>>
>>> Thanks,
>>>
>>> greg
>>>
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170328/a290f61c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook.jpg
Type: image/jpeg
Size: 104849 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170328/a290f61c/attachment-0001.jpg>


More information about the Libraries mailing list