[Haskell-beginners] Type for lists with one or more elements

Frerich Raabe raabe at froglogic.com
Fri Jun 7 05:41:47 CEST 2013


On Jun 6, 2013, at 5:56 PM, Brent Yorgey <byorgey at seas.upenn.edu> wrote:

> On Thu, Jun 06, 2013 at 05:27:11PM -0700, Frerich Raabe wrote:
>> I could do something like
>> 
>>  data List a = Singleton a | Cons a (List a)
>> 
>> but before I go ahead I wonder: is there an existing Haskell package
>> for this? Maybe even with prettier names than what I wrote above, and
>> convenient functions for transforming from/to plain [] lists? It
>> would probably be straightforward to write it myself, but because of
>> that, I suspect that somebody else already did it. :-)
> 
> Yes, this exists in the semigroups package:
> 
>  http://hackage.haskell.org/packages/archive/semigroups/0.9.2/doc/html/Data-List-NonEmpty.html

Awesome, thanks a lot for pointing this out! semigroups… I don't even
know what that would be, pretty sure I wouldn't have found this by
myself. :-}

-- 
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing









More information about the Beginners mailing list