[Haskell-cafe] Re: what does @ mean?.....

Achim Schneider barsoap at web.de
Fri Dec 28 08:45:41 EST 2007


ChrisK <haskell at list.mightyreason.com> wrote:

> zeroNothing Nothing = Nothing
> zeroNothing (Just n) =
>   if n == 0 then Nothing else (Just n)
> 
> versus
> 
> zeroNothing Nothing = Nothing
> zeroNothing x@(Just n) =
>   if n == 0 then Nothing else x
> 
versus

zeroNothing Nothing = Nothing
zeroNothing x =
    let (Just n) = x
    in if n == 0 then Nothing else x

so, @ is kind of like a let, just with its arguments flipped.





More information about the Haskell-Cafe mailing list