[Haskell-cafe] Non Empty List?

Jake McArthur jake.mcarthur at gmail.com
Thu Jun 4 18:53:42 EDT 2009


GüŸnther Schmidt wrote:
> 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 think you meant to do either

     data Container a = Single a | Many a (Container a)

or

     data Container a = Container a [a]

- Jake



More information about the Haskell-Cafe mailing list