Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Evan Laforge
Although equal? treats the two as the *same*, they're different lists because if we modify one (e.g by set-car!) the other won't be affected. So here comes another question: when we say a function always give the same output for the same input, what the *same* means here? ídentity or

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Derek Elkins
On Sun, 2009-01-04 at 16:19 +0800, Evan Laforge wrote: Although equal? treats the two as the *same*, they're different lists because if we modify one (e.g by set-car!) the other won't be affected. So here comes another question: when we say a function always give the same output for the

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Evan Laforge
So it *looks* like there's only one list created in 'lvl1', but I can't see where it's turning into a tuple, and I don't understand the ' = : ' stuff, You're reading it wrong. : is a name. It's lvl5 = (:) @ Char a2 ([] @ Char) where @ is type application (instantiation). Triming that, it's

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Aaron Tomb
On Jan 3, 2009, at 7:28 AM, Xie Hanjian wrote: Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, or (==) is not for identity checking? If the later is true, how can I check two object is the *same* object? As others have

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Thomas Davie
On 4 Jan 2009, at 18:08, Aaron Tomb wrote: On Jan 3, 2009, at 7:28 AM, Xie Hanjian wrote: Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, or (==) is not for identity checking? If the later is true, how can I check two

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Lauri Alanko
On Sun, Jan 04, 2009 at 04:19:38PM +0800, Evan Laforge wrote: If you don't have set-car!, then identity and equality are impossible to differentiate. There's still eqv?. (I wish people wouldn't use eq? as an example of an identity-comparison operation. It's as underdefined as unsafePtrEq.) So

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Ketil Malde
Aaron Tomb at...@galois.com writes: As others have explained, the == operator doesn't tell you whether two values are actually stored at the same location in memory. Nobody yet mentioned that (==) doesn't guarantee *anything* - it's a user defined function. So while it may and should give

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Peter Verswyvelen
Maybe you could use stable names for this: http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html Stable names are a way of performing fast (O(1)), not-quite-exact comparison between objects. Stable names solve the following problem: suppose you want to build a

[Haskell-cafe] How to check object's identity?

2009-01-03 Thread Xie Hanjian
Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, or (==) is not for identity checking? If the later is true, how can I check two object is the *same* object? Thanks Jan -- jan=callcc{|jan|jan};jan.call(jan) pgpJa3i8YUIrV.pgp

Re: [Haskell-cafe] How to check object's identity?

2009-01-03 Thread Xie Hanjian
Thanks guys :-) * Nicolas Pouillard nicolas.pouill...@gmail.com [2009-01-03 16:39:59 +0100]: Excerpts from Xie Hanjian's message of Sat Jan 03 16:28:30 +0100 2009: Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, or

Re: [Haskell-cafe] How to check object's identity?

2009-01-03 Thread Luke Palmer
2009/1/3 Xie Hanjian jan.h@gmail.com Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, Also, in functional programming, *every* function returns the same output for the same input. That's part of the definition of

Re: [Haskell-cafe] How to check object's identity?

2009-01-03 Thread Xie Hanjian
* Luke Palmer lrpal...@gmail.com [2009-01-03 18:46:50 -0700]: 2009/1/3 Xie Hanjian jan.h@gmail.com Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, Also, in functional programming, *every* function returns

Re: [Haskell-cafe] How to check object's identity?

2009-01-03 Thread Luke Palmer
2009/1/3 Xie Hanjian jan.h@gmail.com * Luke Palmer lrpal...@gmail.com [2009-01-03 18:46:50 -0700]: 2009/1/3 Xie Hanjian jan.h@gmail.com Hi, I tried this in ghci: Prelude 1:2:[] == 1:2:[] True Does this mean (:) return the same object on same input, Also,

Re: [Haskell-cafe] How to check object's identity?

2009-01-03 Thread Anton van Straaten
Luke Palmer wrote: I, like many arrogant Haskellers, reject Scheme and other such impure languages as functional. At least until I turn on my brain. If Haskell is functional, then so is Scheme - it's just that Scheme lets you use IORefs and the IO monad without going to nearly as much