[Haskell-beginners] Re: [luca_ciciriello@hotmail.com: Re:
reflection]
Heinrich Apfelmus
apfelmus at quantentunnel.de
Tue Jan 5 13:24:18 EST 2010
Brent Yorgey wrote:
>
> There is no way to actually inspect and modify the structure of a
> running Haskell program in memory; it is simply not stored in a format
> which would let you do this (it is highly optimized and compiled).
There is also a very good theoretical reason for this: referential
transparency.
For example, the expressions 2+4 , 2*3 and 6 all denote the same
integer. Referential transparency means that no function
f :: Int -> Something
may distinguish between equal integers, i.e. it must return the same
result, no matter which of the expressions is given as argument:
f (2+4) = f (2*3) = f 6
Referentially transparency is awesome for reasoning about programs, but
it does preclude many forms of reflection. (A standard trick is to use
type classes to inspect expressions, but you still have to be explicit
about expressions versus the values they denote.)
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
More information about the Beginners
mailing list