[Haskell-cafe] const is question

Jake Mcarthur jake.mcarthur at gmail.com
Sat Jun 14 12:22:28 EDT 2008


On Jun 14, 2008, at 11:14 AM, odtaa48 wrote:

> const id 0   5 -> 5 -- ie. 'takes' the 'last' one

The type of const is a -> b -> a. The first argument to const here is  
id and the second is 0, so the evaluation of const id 0 is going to  
result in id. Then we apply id to 5, yielding 5. Perhaps it would be  
more clear to write the expression is (const id 0) 5.

> const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one

Here the two arguments to const are (id 0) and 5. Since the effect of  
const is to toss out the second argument, this evaluates to id 0,  
which evaluates to simply 0.

Does that help?

- Jake McArthur


More information about the Haskell-Cafe mailing list