3 ms·
Here's another list of factorial implementations in Haskell, which I think does say something about the language and its mindset. Be sure to scroll to the end:
by cousin_it 7y ago
Here's another list of factorial implementations in Haskell, which I think does say something about the language and its mindset. Be sure to scroll to the end: https://www.willamette.edu/~fruehr/haskell/evolution.html https://www.willamette.edu/~fruehr/haskell/evolution.html
Here's another illustration. Since values in Haskell are immutable, implementing something like foo.bar.baz+=1 becomes a bit clunky, so they wrote a library to make it easier. Check it out, especially the diagram that says "simplified": http://hackage.haskell.org/package/lens http://hackage.haskell.org/package/lens
So I agree with the article that Haskell can be dauntingly abstract. (Though you can write code that's perfectly straightforward if you want.)
- kreetx 7y agoBoth field name overloading and deep updates have been problems and are worked on as we speak: https://github.com/ghc-proposals/ghc-proposals/pull/282 https://github.com/ghc-proposals/ghc-proposals/pull/282. And yes, that is what the lens library has been solving till now.
- imglorp 7y agoI would like to see a concerted effort from the Haskell community to set aside the self-gratifying maps and factorials, and show us real work. The OP article, too, focusing on reducing errors, went into the factorial weeds here. How about presenting the air traffic control example in Haskell to contrast with the Ada? Real concurrency, real I/O, and real error cases.
- cousin_it 7y agoI think real I/O and error handling will be about the same in any language. People fall in love with Haskell for other reasons: It's very nice for some algorithms. For example, see Appendix A of this paper: https://pdfs.semanticscholar.org/b47b/41a9b2dcf6b3ffe3ce7a04c49958122b2060.pdf https://pdfs.semanticscholar.org/b47b/41a9b2dcf6b3ffe3ce7a04... An implementation of red-black trees in only 60 lines, including deletion, which alone can take hundreds of lines in a curly brace language. It's also very nice for some APIs. For example, software transactional memory fits the Haskell type system very well, because it can ensure that data can't be modified outside a transaction and can be rolled back when needed. A team at Microsoft, including some well-known folks, tried to port it from Haskell to C# and failed due to the type system: https://www.infoq.com/news/2010/05/STM-Dropped/ https://www.infoq.com/news/2010/05/STM-Dropped/ Haskell has a bunch of non-mainstream features that work together unusually well. It enables programmers to think a certain kind of thoughts that wouldn't naturally arise in many other languages. It's like painting with oil when the rest of the world uses watercolor: in theory they can draw the same things, but in practice they'll guide your hand toward different things, so having both makes the world richer.