News for hackers. Stuff that matters.
Re:Parse, Don’t Validate by iddan on Thursday November 07, 2019 @05:44PM (#21478077)
Dear awesome Haskell writers. You are writing great articles but I can’t understand the code examples as Haskell is too far from the programming languages. Can you provide examples in TypeScript / Rust / Swift / Reason or another C like language? If not, I’m curious why? Love, Iddan
Re:Parse, Don’t Validate by lexi-lambda on Thursday November 07, 2019 @06:45PM (#21478644)
I have provided a translation of the NonEmpty datatype into Java in this comment: https://news.ycombinator.com/item?id=21478322

However, to answer your “why” question: mostly just because I write Haskell for a living, and my primary personal motivation for writing this blog post was to share with my coworkers and to point to during code reviews. Therefore, it makes the most sense for the examples to be in Haskell! Haskell is also especially well-suited for communicating this sort of thing if you already understand the notation, as you can sort of see from the Java translation: it’s significantly more verbose just to get the same idea across. Still, it’d be great if someone were to provide a “translation” of the same ideas to other languages, no doubt!

Re:Parse, Don’t Validate by voxl on Thursday November 07, 2019 @05:50PM (#21478128)
Dead iddan,

Haskell is in fact a programming language, despite what the phrasing of your comment might imply. Translation from language to language is often difficult, we don't do typically do it from English to say Spanish not because it wouldn't be valued but because we may not have the same expertise in Spanish and it would be expensive to hire a person to do it. Expertise is important, because key ideas may get lost in translation.

Re:Parse, Don’t Validate by NieDzejkob on Friday November 08, 2019 @06:58AM (#21481480)
I believe I understood the article completely, even though I haven't written a line of Haskell in my life.
Re:Parse, Don’t Validate by Shacklz on Saturday November 09, 2019 @04:43PM (#21494588)
Since you mentioned typescript first, here's a library that is basically an implementation of the ideas OP tries to convey: https://github.com/gcanti/io-ts

Can't recommend using this library enough; being able to essentially reject any input (e.g. json over http) at runtime because it does not conform to the type definition is such an amazing thing!

Re:Parse, Don’t Validate by papln on Friday November 08, 2019 @12:12PM (#21484293)
One of Haskell's virtues is that it is concise enough to make pleasant reading in a blog post.

Come learn Haskell! It's fun and edificational.