[Haskell-cafe] Re: Pattern matching articles/explanations

Aaron Denney wnoise at ofb.net
Thu Aug 16 17:29:37 EDT 2007


On 2007-08-16, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi
>
>> So what I noticed that "A Gentle Introduction to Haskell" mentioned
>> that wild-cards are useful in constructors. For example:
>>
>> head (x:_) = x
>>
>> So, does that offer any performance benefits over:
>>
>> head (x:xs) = x
>
> No. They are exactly the same. _ simply means "a new unique name".
>
>> Or is it primarily to indicate to the coder that xs is useless?
>
> Yes

And to the compiler that the name won't be used, so it needn't warn you
about not using it.

-- 
Aaron Denney
-><-



More information about the Haskell-Cafe mailing list