[Haskell-cafe] How do you make constant expressions?

Daniel Fischer daniel.is.fischer at web.de
Sun Jul 18 17:19:17 EDT 2010


On Sunday 18 July 2010 23:07:38, Eitan Goldshtrom wrote:
> So just so I get this straight, the following are equivalent to the
> computer, after compiling:
>
> 1.
> fact = 10
> {-# INLINE fact #-}
>
> func x = x * fact
>
> 2.
> func x = x * 10

I'm not sure if they're equivalent when compiled without optimisations, but 
with optimisations, they ought to.
Actually, with optimisations, the inline-pragma shouldn't even be 
necessary.

>
> I'm also curious as to what the {-# #-} brackets represent. I've never
> seen those before.

They mark pragmas, there are a lot of useful pragmas in GHC, take a look at 
the user's guide, section 7.

>
> -Eitan



More information about the Haskell-Cafe mailing list