[Haskell-cafe] Non Empty List?

Miguel Mitrofanov miguelimo38 at yandex.ru
Thu Jun 4 17:55:52 EDT 2009


data Container a = Container a [a] ?

Or, maybe, you need something like zipper.

On 5 Jun 2009, at 01:53, GüŸnther Schmidt wrote:

> Hi,
>
> I need to design a container data structure that by design cannot be  
> empty and can hold n elements. Something like a non-empty list.
>
>
> I started with:
>
> data Container a = Single a | Many a [a]		
>
> but the problem above is that the data structure would allow to  
> construct a Many 5 [] :: Container Int.
>
> I can't figure out how to get this right. :(
>
> Please help.
>
> Günther
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list