On 2012-07-12 23:48, Bulat Ziganshin wrote:
another interesting feature may be ruby-style matching defined by
execution of special function `match` instead of pattern matching:
switch var of
1+1 -> print "var==2"
[5..10] -> print "var in [5..10]"
(>20) -> print "var>20"
where (var `match` (1+1)), (var `match` [5..10]), (var `match` (>20)) is tested
With view patterns you can write
case var of
((== 1+1) -> True) -> print "var==2"
((`elem` [5..10]) -> True) -> print "var in [5..10]"
((> 20) -> True) -> print "var>20"
Or you can just use guards, of course.
Twan
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users