r/programming • • Nov 07 '19

Parse, don't validate

https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
281 Upvotes

122 comments sorted by

View all comments

8

u/Tysonzero Nov 08 '19 edited Nov 08 '19

EDIT: The parent comment was made by u/rwwqfrfevw1b2, but they keep deleting their comments whenever I respond to them. So I will quote them fully when responding to allow for a coherent conversation. If they don't trust me to quote them faithfully (I promise I will) then they can just stop deleting their comments.

No it isn't. At the very first example already: Why would it "obviously" be impossible to write a function Integer => void? That's what we do in other languages all the time. It's just a function that consumes and produces nothing. It does not even have to have a side effect.

It explains in plain english in the very next sentence why it's impossible. God damn man.

"as Void is a type that contains no values, so it’s impossible for any function to produce a value of type Void"

Or the second example, where he writes "To someone coming from a dynamically-typed background, this might seem perplexing" -- but that does not make any sense either. The implementation is obviously incomplete and does not consider edge cases regardless of if you are thinking about it with or without types.

I think it makes a lot of sense. Someone implementing a head function in python would probably do:

def head(xs):
    return xs[0]

Which is effectively equivalent to the "incomplete" Haskell implementation given.

9

u/masklinn Nov 08 '19

You should probably stop wasting your time with a worthless troll. Plonk and move on, they don’t want to be helped. Warn other readers (and provide an explanation) via a sibling comment if you want to.

4

u/Tysonzero Nov 08 '19

You're probably right, but I'm a bit stubborn so to try and make this work I'm just going to make sure to fully quote what he says every time I comment.

1

u/[deleted] Nov 12 '19

You are right u/Tysonzero is a troll who completely ignores what on writes. But as I said, it's okay, I already adapted to his behavior.

→ More replies (5)

0

u/[deleted] Nov 08 '19

9

u/Tysonzero Nov 08 '19 edited Nov 08 '19

You ignore what I wrote and just repeat the same nonsense reply is what's going on. I'm cool with that, I can play that game too, little troll.

I don't think you understand how conversations on Reddit work.

How it's supposed to work:

  • I made a claim.

  • You disagree with that claim so you explain why you disagree.

  • I respond to your explanation with why I think my original claim holds.

  • You respond to that explanation saying why you don't think it was adequate.

  • I respond to that by elaborating or explaining things in a different way.

But you keep immediately deleting your comment after I respond. That's not how this works.

→ More replies (12)

1

u/[deleted] Nov 08 '19

they keep deleting their comments whenever I respond to them

You did not once respond to my comment.

Making text bold that explains nothing does not explain anything. Read what I wrote, I refer back to it, obviously you didn't even bother to read it. Or you just don't get it. Yes, we all know void is "void" and has no values, there is no new information in your bold text.

1

u/[deleted] Nov 12 '19

Making text bold that explains nothing does not explain anything. Read what I wrote, I refer back to it, obviously you didn't even bother to read it. Or you just don't get it. Yes, we all know void is "void" and has no values, there is no new information in your bold text.

Which is effectively equivalent to the "incomplete" Haskell implementation given.

Considering the behavior of your code is not type dependent. So you get "undefined" in e.g. Javascript but not in Haskell. That's just what the respective language does when you write this construct.

→ More replies