
26 May
2011
26 May
'11
2:56 p.m.
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...