News for hackers. Stuff that matters.
Re:Show HN: I built a poker site with Haskell by daenz on Friday August 09, 2019 @04:19PM (#20657946)
Close, but values from os.environ are always string, and not guaranteed to be parsable numbers.
Re:Show HN: I built a poker site with Haskell by icedchai on Friday August 09, 2019 @05:02PM (#20658231)
This is a bit clearer:

    def getSocketAPIPort(defaultport): 
      return int(os.getenv('socketPort', defaultport))
Re:Show HN: I built a poker site with Haskell by daenz on Friday August 09, 2019 @05:13PM (#20658297)
Closer, but int can throw a ValueError. The original Haskell code defaulted to the defaultPort if the specified port could not be cast to an int.
Re:Show HN: I built a poker site with Haskell by icedchai on Friday August 09, 2019 @06:49PM (#20658840)
I see. Though I think it's better to throw an error. I wouldn't want my app just coming up on default port if I had configured it incorrectly.
Re:Show HN: I built a poker site with Haskell by KirinDave on Friday August 09, 2019 @11:45PM (#20660012)
It might be in Python, but it's sorta oranges to apples for you to just not do the same thing your Rosetta code is supposed to do.

What's the value of your exercise if you just redefine the problem to get rid of the tricky part?

Re:Show HN: I built a poker site with Haskell by icedchai on Saturday August 10, 2019 @10:11AM (#20662134)
I’d say the original code was wrong. anyway catching an exception isn’t tricky.
Re:Show HN: I built a poker site with Haskell by KirinDave on Saturday August 10, 2019 @12:08PM (#20662821)
If it's easy then why did you fail twice at even making a valid python expression?

When we talk about the oppressive nature of Python culture—how the "there is only one way to do it" culture leaks out of the place where it's applicable and starts to be focused on other communities that have different requirements—we think of examples like this. "Your code in a language I don't now or use is wrong."

Over focusing on how the example code polls the environment is the least interesting thing you could hyperfocus on. What's more, I think it's a bit more normal to use something like optparse-applicative, which leads to inevitable complaints about using infix operators that every Haskell novice knows but that armchair Haskell programmers hem and haw about asking, "is this too many operators?"

Re:Show HN: I built a poker site with Haskell by icedchai on Saturday August 10, 2019 @12:23PM (#20662922)
I only answered once. The other code was from another guy.
Re:Show HN: I built a poker site with Haskell by KirinDave on Saturday August 10, 2019 @01:33PM (#20663391)
Okay, my apologies. I accept the correction.

Do you want to respond to the rest or just let it stand?

Re:Show HN: I built a poker site with Haskell by icedchai on Saturday August 10, 2019 @04:44PM (#20664426)
I'm going to take another look at Haskell first.