Re: [Haskell-cafe] Re: Non Empty List?

2009-06-05 Thread Ketil Malde
GüŸnther Schmidt gue.schm...@web.de writes: I need a data structure as in my example without the [] being possible to be empty. Well, a list can by definition be empty, so this is clearly impossible. The best you can do is to hide the constructors and have smart constructor functions that

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-05 Thread Ketil Malde
MH mha...@gmail.com writes: data Container a = Many a(Container a) but here is what I don't understand (fyi, I am a beginner) how can you construct this container? I can do let a = Many somestring - and I will get back a function but I can not do let a = Many 'a' somestring - because the

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-05 Thread Jason Dagit
On Fri, Jun 5, 2009 at 2:58 PM, MH mha...@gmail.com wrote: I actually meant data Container a = Many a(Container a) but here is what I don't understand (fyi, I am a beginner) how can you construct this container? I can do I think I saw the above definition described as a coalgebra or

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-05 Thread Luke Palmer
On Fri, Jun 5, 2009 at 4:13 PM, Jason Dagit da...@codersbase.com wrote: On Fri, Jun 5, 2009 at 2:58 PM, MH mha...@gmail.com wrote: I actually meant data Container a = Many a(Container a) but here is what I don't understand (fyi, I am a beginner) how can you construct this container? I

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-04 Thread Dan Weston
Unless I'm missing something in your description, why not data Container a = Single a | Many a a [a] Dan GüŸnther Schmidt wrote: Hi Jake, Jake McArthur schrieb: GüŸnther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above is that the data structure would

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-04 Thread Tillmann Rendel
Hi Günther, GüŸnther Schmidt wrote: data Container a = Single a | Many a [a] but the problem above I need a data structure as in my example without the [] being possible to be empty. So lets write a variant of list which cannot be empty. A usual list is empty, or a head and a tail:

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-04 Thread Tony Morris
I note that you didn't address the suggestion of a zipper. GüŸnther Schmidt wrote: Dan Weston schrieb: Unless I'm missing something in your description, why not data Container a = Single a | Many a a [a] Hi Dan, the above solution would still allow to construct, for instance, Many 5

Re: [Haskell-cafe] Re: Non Empty List?

2009-06-04 Thread Jeff Wheeler
On Fri, 2009-06-05 at 02:08 +0200, GüŸnther Schmidt wrote: As for the zipper: In some of the examples I've seen, the zipper is implemented on top of an underlying data structure, but not the data structure itself. In my app I was actually going to pull a zipper over it, once I had the