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 (==) ::
Person Person to just integer comparison.)

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 becomes pointer equity.

OTOH, I am not a GHC developer...

...and what I *should* of course have written is "go benchmark it". ;-)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to