Dan Weston schrieb:
> If you have a long if/else if/else chain, you might consider a trivial
> case statement with guards. Whether you think this is attractive is a
> matter of taste, but it has the fall-through semantics you want and ghc
> optimizes the _ pattern matching away:
> 
> f x = case () of
>   _| x == 2    -> 22
>   _| x == 4    -> 44
>   _| x == 7    -> 77
>   _| otherwise -> 55
> 
>> f 4
> 44
>> f 9
> 55

http://www.haskell.org/haskellwiki/Case

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to