4 ms·
In what way is Haskell's pattern matching not as clever as Erlang's?
by subleq 13y ago
In what way is Haskell's pattern matching not as clever as Erlang's?
- lostcolony 13y agoIt shows later in the slideshow, no? Slides 40-41.
- subleq 13y agoI see, it's just the non-linear patterns? Looks like they were considered for Haskell and there are some good arguments against them: http://www.mail-archive.com/haskell@haskell.org/msg03721.html http://www.mail-archive.com/haskell@haskell.org/msg03721.htm....
- lostcolony 13y agoI don't know if it's only; didn't see the talk. I can see why to exclude it, but Erlang has everything in place to make its inclusion a very obvious ones. All data types are comparable, for ill or for good (I've been both helped and hurt by it), and allowing non-linear patterns makes for some very clean pattern matching code for many recursive functions.
- nox_ 13y agoYes, Erlang patterns are non-linear, Haskell has view patterns. Neither are more powerful than the other. They are just different. Erlang non-linear patterns fit more with the semantics of match where an already bound name isn't shadowed, view patterns fit well into Haskell because of the ensured purity.
- peteretep 13y agoConsider: evaluate([ A,A,A, _,_,_, _,_,_ ]) when A != b -> { winner, A }; evaluate([ _,_,_, A,A,A, _,_,_ ]) when A != b -> { winner, A }; evaluate([ _,_,_, _,_,_, A,A,A ]) when A != b -> { winner, A }; I don't think I can do that as eloquently in Haskell using pattern matching, but I'd love for you to show me.