Re:Intro to Haskell for Erlangers
by subleq on Sunday March 09, 2014 @03:17PM
(#7369542)
In what way is Haskell's pattern matching not as clever as Erlang's?
[ Parent
| on HN ]
Re:Intro to Haskell for Erlangers
by lostcolony on Sunday March 09, 2014 @03:25PM
(#7369570)
It shows later in the slideshow, no? Slides 40-41.
I 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/[email protected]/msg03721.htm....
Re:Intro to Haskell for Erlangers
by lostcolony on Sunday March 09, 2014 @05:31PM
(#7370050)
I 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.
Yes, 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.
Consider:
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.