Live data from Hacker News

Show HN: I built a poker site with Haskell

github.com

71–80 of 121 posts

Re: Show HN: I built a poker site with Haskell

#71
post #8
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

Haskell is dense. I'm picking it up now[0], so this project was very useful for me to see how some "real world" Haskell is written. But yes, take for example this function getSocketAPIPort :: Int -> IO Int getSocketAPIPort defaultPort = do maybeEnvPort return defaultPort Just port -> maybe (return defaultPort) return (readMaybe port) It gets a port from an environment variable, if it can, otherwise a default port. Co…

monad transformers can help alot here:

  getSocketAPIPort :: Int -> IO Int
  getSocketAPIPort defaultPort =
    fromMaybe defaultPort  runMaybeT do
      envPort 

Re: Show HN: I built a poker site with Haskell

#72
post #56
post #7

Earlier quoted context omitted.

Yes this project is active. That would be awesome if you contributed. There are a lot of features to add. Would you like me to add some of these to the issues on Github? Feel free to add your own suggestions to the issues as well.

That'd be great! I saw some todos, but you'll have the best perspective on what's important. I'm https://github.com/Gandalf-

Ok I have added some things to work on to the issues. Feel free to pick one up or add your own. :)

Re: Show HN: I built a poker site with Haskell

#73

What would be the best IDE/editor for Haskell?

Emacs works very well. Haskell is the second best emacs experience I've ever had, second only to Lisp. Things were not always this way. Just a few years ago, it was a bad experience, so if you have bad memories, it may be time to try again.

I used Haskell on Emacs a few weeks ago and there still seems to be some issues with regards indentation.

Re: Show HN: I built a poker site with Haskell

#74
post #68

Earlier quoted context omitted.

in python: def getSocketAPIPort(defaultport): try: return os.environ["socketPort"] except KeyError: return defaultport

Close, but values from os.environ are always string, and not guaranteed to be parsable numbers.

This is a bit clearer:

    def getSocketAPIPort(defaultport): 
      return int(os.getenv('socketPort', defaultport))

Re: Show HN: I built a poker site with Haskell

#75
post #68

Earlier quoted context omitted.

Close, but values from os.environ are always string, and not guaranteed to be parsable numbers.

This is a bit clearer: def getSocketAPIPort(defaultport): return int(os.getenv('socketPort', defaultport))

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

#77
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

> Is it just me[?]

It's not just you, I came here to say the same thing. I just feel dumb when I try to read Haskell, though I've been using Clojure in production for over 5 years.

Re: Show HN: I built a poker site with Haskell

#78
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

The nice thing about Haskell from a readability standpoint is to unpack what code does at any point, you only have to perform substitution (i.e. beta reduction) over and over. This is a key difference from most other programming languages, which require you to have a little VM in your head. "Localized reasoning" is what Haskellers call this. To read it quickly, you do have to learn & internalize abstractions. Both a…

You mean that decomposing abstractions with substitution works better in Haskell than in a lot of the other languages because programs in Haskell are essentially (pure) functions and abstractions are built by composing functions?

Re: Show HN: I built a poker site with Haskell

#79
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

Game servers aren’t typical. Texas Hold’Em especially. Like a chat application is also multi-user real-time. It’s obvious that when a chat participant disconnects you hold onto the messages to deliver to them for later. When you disconnect from a Texas Hold’em online and you were small blind, what should you do? Wait? Shift the blinds over? The next player in line gets big or small? Copy the leading product’s behavio…

> This is a great Haskell demo because it shows that you can’t hide this code anywhere. It stares back at you with all its ugliness.

i enjoyed your comment and these last two lines in particular. different programmers might interpret these lines in completely different ways: one as a critique of haskell for not being able to tidy the details away to make the code appear simpler, another as praise of haskell for making these mechanics explicit.

Re: Show HN: I built a poker site with Haskell

#80
post #2

So, I know literally nothing about Haskell, and I would rate my knowledge of functional programming theory as 'beginner' at best, but I still get baffled every time when reading Haskell code that implements anything other than something trivial like a fibonacci sequence. The poker server code looks extremely tidy and well engineered, so that can't be the problem, but to me it's utterly incomprehensible. It seems like…

Game servers aren’t typical. Texas Hold’Em especially. Like a chat application is also multi-user real-time. It’s obvious that when a chat participant disconnects you hold onto the messages to deliver to them for later. When you disconnect from a Texas Hold’em online and you were small blind, what should you do? Wait? Shift the blinds over? The next player in line gets big or small? Copy the leading product’s behavio…

Our ways to hide that logic has been building libraries that handle nearly all of it.

But since Haskell's ecosystem is small by comparison a lot of that logic leaks to your own application code. Especially when dealing with something like stateful websocket applications.

Post reply on HN