[Haskell-cafe] How do you make constant expressions?
Jesper Louis Andersen
jesper.louis.andersen at gmail.com
Sun Jul 18 16:27:16 EDT 2010
On Sun, Jul 18, 2010 at 10:19 PM, Eitan Goldshtrom
<thesourceofx at gmail.com> wrote:
> Silly question, but I can't find the answer on the net. I think I'm just
> using the wrong words in my search. I'm looking for a way to create constant
> expressions in Haskell. The C/C++ equivalent of what I'm talking about is
>
> #define NAME VALUE
NAME = VALUE
the inliner should easily take care of it, if VALUE is a constant.
Note that in the designation above, NAME will *be* a constant value
due to the functional aspect of Haskell (it can't change later on).
You need the discrimination in C because something like
int NAME = VALUE;
defines a global variable, which may change and hence cannot be inlined.
--
J.
More information about the Haskell-Cafe
mailing list