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@gmail.com> wrote:


On Tue, Mar 28, 2017 at 12:48 PM, David Feuer <david.feuer@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@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@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries