4 ms·
This 80-line solution sounds very interesting. I'd love to see more examples of this particular strength of Haskell. Are there similar parsing projects that you
by hellofunk 10y ago
This 80-line solution sounds very interesting. I'd love to see more examples of this particular strength of Haskell. Are there similar parsing projects that you can point to that are open source and worth looking at to better understand this use case of Haskell?
- PinkyThePiggy 10y agoHere is an example from Real World Haskell (pretty good intermediate book, although it is a bit dated): http://book.realworldhaskell.org/read/using-parsec.html#csv http://book.realworldhaskell.org/read/using-parsec.html#csv A fully featured CSV parser in 20-30 [depending on how you count] lines of non-golf code.
- hellofunk 10y agoI'm curious what aspects of Haskell have changed to cause this book to be dated, i.e. are there examples in this book which would be done differently now?
- PinkyThePiggy 10y agoAs one example, a lot of the libraries referenced in the book have gone through major version changes (1.x to 2.x etc.) that change the functions being exported and/or architecture reworks changing which libraries you need to import which means that if you try to copy + compile a lot of the code snippets, they will not compile. It is generally trivial changes in most cases, but if you are a newbie to the language, it is likely not immediately obvious because you will think you copied from the book wrong (or that the book has a typo) instead of the libraries having been changed. There is also a lot written about historical quirks you will come across that have since been fixed.
- luisfoliv 10y agoThis SO thread is very informative in this regard: http://stackoverflow.com/questions/23727768/which-parts-of-real-world-haskell-are-now-obsolete-or-considered-bad-practice http://stackoverflow.com/questions/23727768/which-parts-of-r...
- gh02t 10y agoI remembered a bit wrong, the final version was 155 lines (I think my first stab was ~80 lines). I have a version of it on Github as a gist https://gist.github.com/jasonmhite/c4c56d4c50fc673e658b71b8286c390d https://gist.github.com/jasonmhite/c4c56d4c50fc673e658b71b82... . Can't really claim whether or not it's "good" Haskell or that it's optimal, but it gets the job done. I also dunno how comprehensible it is without knowing the ins-and-outs of the nPOD format or multiplicity counting, but hey there it is. Not sure of what the definitive reference is, but this article is pretty good I think: https://www.schoolofhaskell.com/school/starting-with-haskell/libraries-and-frameworks/text-manipulation/attoparsec https://www.schoolofhaskell.com/school/starting-with-haskell...