Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-29 Thread Stephen Tetley
On 30 May 2011 05:27, Anupam Jain wrote: > Why doesn't Haskell have built in syntactic sugar for atoms? Because they don't have a functional interpretation? (i.e. they're really a hack) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-29 Thread Don Stewart
> Why doesn't Haskell have built in syntactic sugar for atoms? > -- Anupam I think because of deriving Enum. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-29 Thread Anupam Jain
On Thu, May 26, 2011 at 7:26 PM, Gregory Collins wrote: > Based on the description it looks like you could be looking for: > >http://hackage.haskell.org/package/simple-atom > > G > > Coincidentally, I put up a question at stackoverflow for this just yesterday - http://stackoverflow.com/questio

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Andrew Coppin
On 26/05/2011 07:56 PM, Andrew Coppin wrote: On 26/05/2011 10:59 AM, Jacek Generowicz wrote: Any comments on the relative efficiency of the above as compared to A == B in the context of data Foo = A | B | C | D | ... lots more ... ? (I imagine that a Sufficiently Smart Compiler could reduce

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Brandon Allbery
On Thu, May 26, 2011 at 14:56, Andrew Coppin wrote: > My understanding is that if you have a constructor with no fields, it gets > allocated as a compile-time constant. In other words, "C" is just a pointer > to a static data structure somewhere in the program binary, and (==) > effectively become

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Andrew Coppin
On 26/05/2011 10:59 AM, Jacek Generowicz wrote: Any comments on the relative efficiency of the above as compared to A == B in the context of data Foo = A | B | C | D | ... lots more ... ? (I imagine that a Sufficiently Smart Compiler could reduce (==) :: Person Person to just integer compari

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Simon Meier
2011/5/26 Jacek Generowicz : > > On 2011 May 26, at 11:16, Christopher Done wrote: > >> On 26 May 2011 10:45, Jacek Generowicz wrote: >>> >>> What is the Haskell approach to efficient comparison and lookup of >>> objects >>> by their identity? >> >> Often you just provide your own and implement Eq

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Gregory Collins
Based on the description it looks like you could be looking for: http://hackage.haskell.org/package/simple-atom G On Thu, May 26, 2011 at 10:45 AM, Jacek Generowicz wrote: > [ TLDR: How do you do Lisp symbols in Haskell? ] > > > What is the Haskell approach to efficient comparison and looku

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Jacek Generowicz
On 2011 May 26, at 11:59, Jacek Generowicz wrote: (I imagine that a Sufficiently Smart Compiler could reduce (==) :: Person Person to just integer comparison.) Sorry, I meant (==) :: Person -> Person -> Bool in the above. ___ Haskell-Cafe maili

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Jacek Generowicz
On 2011 May 26, at 11:59, Brandon Allbery wrote: On Thu, May 26, 2011 at 05:41, Jacek Generowicz > wrote: On 2011 May 26, at 11:12, Brandon Allbery wrote: (Think gensym. Hm, except last time I did anything serious with Lisp, it was Maclisp... does gensym even still exist, or did CL do some

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Brandon Allbery
On Thu, May 26, 2011 at 05:41, Jacek Generowicz wrote: > On 2011 May 26, at 11:12, Brandon Allbery wrote: > >> (Think gensym. Hm, except last time I did anything serious with Lisp, it >> was Maclisp... does gensym even still exist, or did CL do something >> inscrutable with it?) > > > But gensym

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Jacek Generowicz
On 2011 May 26, at 11:16, Christopher Done wrote: On 26 May 2011 10:45, Jacek Generowicz wrote: What is the Haskell approach to efficient comparison and lookup of objects by their identity? Often you just provide your own and implement Eq. I should be able to run the program on data tha

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Jacek Generowicz
On 2011 May 26, at 11:12, Brandon Allbery wrote: On Thu, May 26, 2011 at 04:45, Jacek Generowicz > wrote: What is the Haskell approach to efficient comparison and lookup of objects by their identity? ghc uses Data.Unique to generate unique internal identifiers to associate with things. A

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Christopher Done
On 26 May 2011 10:45, Jacek Generowicz wrote: > What is the Haskell approach to efficient comparison and lookup of objects > by their identity? Often you just provide your own and implement Eq. > I should be able to run the program on data that becomes available at run > time. Typically you def

Re: [Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Brandon Allbery
On Thu, May 26, 2011 at 04:45, Jacek Generowicz wrote: > What is the Haskell approach to efficient comparison and lookup of objects > by their identity? > ghc uses Data.Unique to generate unique internal identifiers to associate with things. (Think gensym. Hm, except last time I did anything se

[Haskell-cafe] Efficient object identity (aka symbols as data)

2011-05-26 Thread Jacek Generowicz
[ TLDR: How do you do Lisp symbols in Haskell? ] What is the Haskell approach to efficient comparison and lookup of objects by their identity? Maybe a toy example would help to explain what I mean. Imagine that I want to use Haskell to maximize happiness in a situation where a bunch of pe