Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-28 Thread Hans Aberg
I have fixed the problem now. In the last letter, with the Natural class, I had not added instance Num Natural where (N x) - (N y) = N(x - y) which the Ordinal class then in fact has one. Then it turns out that it is merely the fact that "show" had some cases looking at the list length

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-28 Thread Hans Aberg
On 28 Mar 2008, at 03:03, Ryan Ingram wrote: Another way to defer the evaluation of the second argument of (-+) is like this: (-+) :: a -> List a -> List a x -+ y = List(f) where f 0 = x f k = case y of List g -> g (k-1) This is exactly what the lazy pattern will do at compile-time. Does

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-28 Thread Hans Aberg
On 28 Mar 2008, at 03:03, Ryan Ingram wrote: Another way to defer the evaluation of the second argument of (-+) is like this: (-+) :: a -> List a -> List a x -+ y = List(f) where f 0 = x f k = case y of List g -> g (k-1) This is exactly what the lazy pattern will do at compile-time. Doe

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-28 Thread Hans Aberg
On 28 Mar 2008, at 03:03, Ryan Ingram wrote: Another way to defer the evaluation of the second argument of (-+) is like this: (-+) :: a -> List a -> List a x -+ y = List(f) where f 0 = x f k = case y of List g -> g (k-1) This is exactly what the lazy pattern will do at compile-time. Th

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Ryan Ingram
Another way to defer the evaluation of the second argument of (-+) is like this: (-+) :: a -> List a -> List a x -+ y = List(f) where f 0 = x f k = case y of List g -> g (k-1) This is exactly what the lazy pattern will do at compile-time. Does this give you a better understanding of how lazy

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
On 27 Mar 2008, at 17:51, Luke Palmer wrote: A more standard way to do this would be: data List a = List (Ordinal -> a) Ordinal I used data List a = Empty | (Ordinal->a) :+ Ordinal which might then be simplified by dropping "Empty". Hans Aberg __

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
On 27 Mar 2008, at 17:51, Luke Palmer wrote: By your naming, am I correct in assuming that you're implementing transfinite lists? If so, cool! Yes, it is an old idea I brought up now. If list length is written also for infinite lists, then concatenated lists get indexed by the sum of their

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Luke Palmer
A few comments: On Thu, Mar 27, 2008 at 2:55 PM, Hans Aberg <[EMAIL PROTECTED]> wrote: > The reason I used a "data" construct was that I include the size of > the list, excluded in order to keep the example as simple as possible: >data List a = List(Ordinal -> a, Ordinal) This could still b

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
On 27 Mar 2008, at 15:58, Miguel Mitrofanov wrote: Hmmm, seems like your (-+) is not lazy enough. ... You can fix it by defining (-+) as x -+ ~(List y) = ... Yes, this has been pointed out... Since pattern matching is strict by default, you have anything -+ (_|_) = (_|_) Therefore, the

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Miguel Mitrofanov
Hmmm, seems like your (-+) is not lazy enough. Since pattern matching is strict by default, you have anything -+ (_|_) = (_|_) Therefore, the function, which is constantly (_|_), is a fixed point for the equation defining h. In other words, if you define h' x = undefined then you have h'

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
On 27 Mar 2008, at 15:32, Luke Palmer wrote: More to the point, if List is declared as: newtype List a = List (Integer -> a) Instead of with "data", it also works. The problem, as was stated, was that -+ is too strict. That is, without the ~ there, -+ evaluates its right argument to make

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
On 27 Mar 2008, at 15:18, Claude Heiland-Allen wrote: The combination of (-+) and h is too strict, this modification works: (-+) :: a -> List a -> List a x -+ ~(List y) = List(f) where -- lazy pattern match f 0 = x f k = y(k-1) Thank you for the fast response. Yes, that might be what I

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Luke Palmer
On Thu, Mar 27, 2008 at 2:18 PM, Claude Heiland-Allen > The combination of (-+) and h is too strict, this modification works: > > > (-+) :: a -> List a -> List a > x -+ ~(List y) = List(f) where -- lazy pattern match > >f 0 = x >f k = y(k-1) More to the point, if List is declared as:

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Claude Heiland-Allen
Hans Aberg wrote: When experimenting with list index sets (i.e. lists more general than provided by Haskell), I arrived at the problem that in the example code below for example h(list 6) does not (in Hugs) write out the beginning of the list lazily. It does work for list 6 first (list

[Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Hans Aberg
When experimenting with list index sets (i.e. lists more general than provided by Haskell), I arrived at the problem that in the example code below for example h(list 6) does not (in Hugs) write out the beginning of the list lazily. It does work for list 6 first (list 6) rest (list