Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-12-11 Thread Paul Hudak
Another belated reply to an old thread... Andrew Pimlott wrote: > On Fri, Nov 18, 2005, Paul Hudak wrote: > > unwind :: Expr -> Expr > > unwind (Add e1 e2) = Add (unwind e1) (unwind e2) > > unwind (Rec fe)= x where x = unwind (fe x) > > unwind e = e > > Since this discussion started

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-12-06 Thread Benjamin Franksen
On Sunday 27 November 2005 11:28, [EMAIL PROTECTED] wrote: > Andrew Pimlott: > > //about my highly spiritual essay on lazy computing of PI//: > > In addition to being clever and terribly funny, the conclusion > > foreshadows (inspired?) later work on Enron [1]. > > Come on, it is improbable that M

RE: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-28 Thread Simon Peyton-Jones
| Andrew Pimlott: | //about my highly spiritual essay on lazy computing of PI//: | | > In addition to being clever and terribly funny, the conclusion | > foreshadows (inspired?) later work on Enron [1]. | | Come on, it is improbable that Master Simon ever read my essay... I hadn't before, but I

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-27 Thread jerzy . karczmarczuk
Andrew Pimlott: //about my highly spiritual essay on lazy computing of PI//: In addition to being clever and terribly funny, the conclusion foreshadows (inspired?) later work on Enron [1]. Come on, it is improbable that Master Simon ever read my essay... No,... no comparison. His work on c

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-27 Thread Andrew Pimlott
On Fri, Nov 18, 2005 at 11:37:40AM -0500, Paul Hudak wrote: > This is a very late response to an old thread... ditto :-) > > unwind :: Expr -> Expr > > unwind (Add e1 e2) = Add (unwind e1) (unwind e2) > > unwind (Rec fe)= x where x = unwind (fe x) > > unwind e = e Since this discus

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-26 Thread Andrew Pimlott
On Sat, Nov 19, 2005 at 02:27:06AM +0100, Benjamin Franksen wrote: > [You should read some of his papers, for instance "the most unreliable > techique in the world to compute pi". I was ROTFL when I saw the title > and reading it was an eye-opener and fun too.] In addition to being clever and te

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-20 Thread Benjamin Franksen
On Saturday 19 November 2005 11:56, Gracjan Polak wrote: > 2005/11/19, Benjamin Franksen > > > [You should read some of his papers, for instance "the most > > unreliable techique in the world to compute pi". I was ROTFL when I > > saw the title and reading it was an eye-opener and fun too.] > > Car

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-19 Thread Jacob Nelson
http://users.info.unicaen.fr/~karczma/arpap/ On Sat, 19 Nov 2005, Gracjan Polak wrote: 2005/11/19, Benjamin Franksen [You should read some of his papers, for instance "the most unreliable techique in the world to compute pi". I was ROTFL when I saw the title and reading it was an eye-opener

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-19 Thread Gracjan Polak
2005/11/19, Benjamin Franksen > [You should read some of his papers, for instance "the most unreliable > techique in the world to compute pi". I was ROTFL when I saw the title > and reading it was an eye-opener and fun too.] > Care to post a link? Seems interesting, but unknown to google :) -- G

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Benjamin Franksen
On Saturday 19 November 2005 02:16, Greg Woodhouse wrote: > --- [EMAIL PROTECTED] wrote: > > fix f = f (fix f) -- Here you have your Y. No typeless lambda. > > > > g f n = n : f n-- This is a generic *non-recursive* `repeat` > > ones = fix g 1 -- Guess what. > > Very nice! I honestly woul

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Greg Woodhouse
--- [EMAIL PROTECTED] wrote: > > fix f = f (fix f) -- Here you have your Y. No typeless lambda. > > g f n = n : f n-- This is a generic *non-recursive* `repeat` > ones = fix g 1 -- Guess what. > > Very nice! I honestly would not have expected this to work. Simple cases of lazy eva

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread jerzy . karczmarczuk
My simple-mindness and naïveté begin to bother me. I begin to get lost, and I don't know anymore what is the problem... Greg Woodhouse a écrit: --- Paul Hudak <[EMAIL PROTECTED]> wrote: ... The important property of Y is this: Y f = f (Y f) Right. This is just a formal statement of the pro

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Lennart Augustsson
Greg Woodhouse wrote: --- Paul Hudak <[EMAIL PROTECTED]> wrote: The important property of Y is this: Y f = f (Y f) Right. This is just a formal statement of the property thaat f fixex Y f. I'm with you so far. In this way you can see it as "unwinding" the function, one step at a time.

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Greg Woodhouse
--- Paul Hudak <[EMAIL PROTECTED]> wrote: > > The important property of Y is this: > > Y f = f (Y f) Right. This is just a formal statement of the property thaat f fixex Y f. I'm with you so far. > > In this way you can see it as "unwinding" the function, one step at a > > time. If we defi

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Paul Hudak
Greg Woodhouse wrote: --- Paul Hudak <[EMAIL PROTECTED]> wrote: Y (\ones. cons 1 ones) where Y (aka the "paradoxical combinator" or "fixed point combinator") is defined as: \f. (\x. f (x x)) (\x. f (x x)) Now, this is I have seen, but it frankly strikes me as a "formal trick". I've never fel

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Greg Woodhouse
--- Paul Hudak <[EMAIL PROTECTED]> wrote: > > I suspect from your other post that you haven't seen the standard > trick of encoding infinite data structures as fixpoints. Suppose you > have a lambda calculus term for cons, as well as for the numeral 1. > Then the infinite list of ones is just:

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Paul Hudak
Greg Woodhouse wrote: > --- Paul Hudak <[EMAIL PROTECTED]> wrote: >>Tom Hawkins wrote: >> > In a pure language, is it possible to detect cycles in recursive >> > data structures? For example, is it possible to determine that >> > "cyclic" has a loop? ... >> > >> > data Expr = Constant Int | Addit

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Paul Hudak
Henning Thielemann wrote: On Fri, 18 Nov 2005, Paul Hudak wrote: For example: fe1,fe2 :: Fix Expr fe1 e = Add (Const 1) (Const 1) -- non-recursive fe2 e = Add (Const 1) e -- recursive Do you mean fe1 _ = Add (Const 1) Loop ? No, I really meant it as written. I included this examp

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Greg Woodhouse
--- Paul Hudak <[EMAIL PROTECTED]> wrote: > This is a very late response to an old thread... > > Tom Hawkins wrote: > > In a pure language, is it possible to detect cycles in recursive > > data structures? For example, is it possible to determine that > > "cyclic" has a loop? ... > > > >

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Henning Thielemann
On Fri, 18 Nov 2005, Paul Hudak wrote: For example: fe1,fe2 :: Fix Expr fe1 e = Add (Const 1) (Const 1) -- non-recursive fe2 e = Add (Const 1) e -- recursive Do you mean fe1 _ = Add (Const 1) Loop ? ___ Haskell-Cafe mailing list Haskel

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-18 Thread Paul Hudak
This is a very late response to an old thread... Tom Hawkins wrote: > In a pure language, is it possible to detect cycles in recursive > data structures? For example, is it possible to determine that > "cyclic" has a loop? ... > > data Expr = Constant Int | Addition Expr Expr > > cyclic :: Expr

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Bulat Ziganshin
Hello Tom, Thursday, October 27, 2005, 6:46:41 PM, you wrote: TH> In a pure language, is it possible to detect cycles in recursive data TH> structures? no, but it is possible in GHC. Einar Karttunen in his "SerTH - Binary Serialization library for Haskell" used makeStableName and unsafeCoerce#

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Nils Anders Danielsson
On Thu, 27 Oct 2005, Lennart Augustsson <[EMAIL PROTECTED]> wrote: > Tom Hawkins wrote: > >> Or phased differently, is it possible to make "Expr" an instance of >> "Eq" such that cyclic == cyclic is smart enough to avoid a recursive >> decent? > > No. And there is nothing that says that your defi

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Iavor Diatchki
Hello, On 10/27/05, Tom Hawkins <[EMAIL PROTECTED]> wrote: > ... > >> data Expr = Constant Int | Addition Expr Expr > >> > >> cyclic :: Expr > >> cyclic = Addition (Constant 1) cyclic > ... > > And there is nothing that says that your definition of cyclic > > will actually have a cycle in the imp

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Lennart Augustsson
Tom Hawkins wrote: Lennart Augustsson wrote: Tom Hawkins wrote: In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: Expr cyclic = A

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Tom Hawkins
Lennart Augustsson wrote: Tom Hawkins wrote: In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: Expr cyclic = Addition (Constant 1)

Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Lennart Augustsson
Tom Hawkins wrote: In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: Expr cyclic = Addition (Constant 1) cyclic Or phased different

[Haskell-cafe] Detecting Cycles in Datastructures

2005-10-27 Thread Tom Hawkins
In a pure language, is it possible to detect cycles in recursive data structures? For example, is it possible to determine that "cyclic" has a loop? ... data Expr = Constant Int | Addition Expr Expr cyclic :: Expr cyclic = Addition (Constant 1) cyclic Or phased differently, is it possible t