Live data from Hacker News

A Dead-Simple Web Stack in Haskell

williamyaoh.com

91–100 of 120 posts

Re: A Dead-Simple Web Stack in Haskell

#91
post #82

Earlier quoted context omitted.

> a file saying "hello world" is enough to get the text to show on a browser Wrong. A file saying "hello world" does not even serve its contents through HTTP on port 80, contrary to the node.js-example you are arguing against. Good luck setting up that Apache monstrosity (as it was common back then) without any "programming knowledge whatsoever". But yeah, I guess your mentioned stockholm syndrome is a thing for PHP…

It sounds like you've never actually used PHP. Even way back when, you could pick from multiple pre-packaged solutions (XAMPP, WAMP, etc). In windows, the installer was a no-brainer click-through wizard, much like any other random software you'd find on sourceforge or whatever. And not only it would setup apache, but also mysql. Then you could click a button to turn on PHP (so no need to type anything in terminal eit…

> you could pick from multiple pre-packaged solutions

> like any other random software you'd find on sourceforge or whatever

> could click a button to turn on PHP

> etc.

tl;dr you don't need to know anything. Good summary of why PHP in production "back the days" was usually of very poor quality.

Re: A Dead-Simple Web Stack in Haskell

#92
post #44

This is a great tutorial for getting up and running fast. I started off with Spock too but grew out of it pretty quickly. It's painful in Haskell you're learning it but feel you're not able to generate anything real for the first month(s) with it. Unfortunately, there's not many up-to-date tutorials like these available for beginners.

Do you have any recommendations for next steps beyond Spock? I learned Haskell at uni and am interested in going back to it for web work (instead of Erlang). Any insights you might be able to share would be really helpful!

Servant. It takes a while to pick it up but it's well worth the effort. You end up with an automatically documented type safe API and you can even generate client functions for other languages using Swagger based on the spec. It has excellent documentation too, the only hard part really is figuring out the handler pattern.

As for the SQL story, that's more fragmented. I'm still trying to figure out the best next step myself. I started off with Persistent & Esqueleto but now looking at BEAM, Selda and Squeal for more control over the queries.

If you use Persistent as the persistence layer, check out Matt Parsons' blog for a nice intro: https://www.parsonsmatt.org/2016/07/08/servant-persistent_up...

I'm actually coming from Elixir myself. I have to admit Haskell feels funny at times but admittedly a lot more robust.

Re: A Dead-Simple Web Stack in Haskell

#93
post #32

Earlier quoted context omitted.

There is this great talk 'stick to simple Haskell' along those lines, but unfortunately it is hosted here https://skillsmatter.com/skillscasts/14133-stick-to-simple-h... Unfortunately I can't find it anywhere else, but it is worth keeping your ears out in case it pops up somewhere..

The link doesn't work.

Yeah, sadly skillsmatter have gone bust so all their content has disappeared. Its a huge shame as there was so much good stuff there. I really hope it will resurface soon..

Re: A Dead-Simple Web Stack in Haskell

#94
post #82

Earlier quoted context omitted.

It sounds like you've never actually used PHP. Even way back when, you could pick from multiple pre-packaged solutions (XAMPP, WAMP, etc). In windows, the installer was a no-brainer click-through wizard, much like any other random software you'd find on sourceforge or whatever. And not only it would setup apache, but also mysql. Then you could click a button to turn on PHP (so no need to type anything in terminal eit…

> you could pick from multiple pre-packaged solutions > like any other random software you'd find on sourceforge or whatever > could click a button to turn on PHP > etc. tl;dr you don't need to know anything. Good summary of why PHP in production "back the days" was usually of very poor quality.

[deleted]

Re: A Dead-Simple Web Stack in Haskell

#95

Earlier quoted context omitted.

Fair enough there are some combinations of compiler extensions that don't interact well and I've written enough type level code to know which ones to stay away from. The C++ move semantics are standard though and have lots of unintended consequences to make easy-to-describe constructors incredibly difficult to implement in practice. My point was that saying Haskell is extremely complex is not technically correct. It'…

> It's a qualitative statement and disingenuous. Complex relative to what? Complex relative to most programming languages. C++ is more complex. That says very little. C++ is an extreme outlier. I think Haskellers do a disservice to people they're trying to convince to do haskell by saying it's not complex. Haskell has a zillion extensions and crazy features, most of which show up in at least some popular Hackage libr…

You are confusing language with ecosystem.

If you we are talking language only, only lisps are simpler.

Re: A Dead-Simple Web Stack in Haskell

#96
post #71

Earlier quoted context omitted.

While you can theoretically get to this level of simplicity with various tools I think the difference isn't so much "can it be this simple?" so much as "does this level of simplicity fit my needs?" and that can be harder to quantify. The same thing you wrote in PHP done in Node.js in an arbitrarily named file served from root: require('http').createServer((_, res) => res.end('Hello World')).listen(80); Zero configura…

Eh, that's not a great example. It can be hard to appreciate the simplicity of PHP when one's fully bought into the stockholm syndrome of another language/framework :) Consider this: a hello world in PHP requires no knowledge of programming whatsoever: a file saying "hello world" is enough to get the text to show on a browser. Having two different pages requires no knowledge of if statements, nor of 404 handling. On…

I despise PHP, but those are words of truth. The first time developer experience in vanilla PHP is the most friendly and easy as you can get, cannot be compared against Next.js, AspNetCore, Flask, Express.js, or any other framework in any other language I could imagine.

Re: A Dead-Simple Web Stack in Haskell

#97

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

While you can theoretically get to this level of simplicity with various tools I think the difference isn't so much "can it be this simple?" so much as "does this level of simplicity fit my needs?" and that can be harder to quantify. The same thing you wrote in PHP done in Node.js in an arbitrarily named file served from root: require('http').createServer((_, res) => res.end('Hello World')).listen(80); Zero configura…

[deleted]

Re: A Dead-Simple Web Stack in Haskell

#98

I love this. I'm a Haskell newbie, I only do Haskell in my spare time, only sometimes, so I don't have time to hunt around for recipes. Kudos to the author, I'll surely borrow from this. --- I also built a simple web server in Haskell for triggering commands via GitHub's Webhooks [1]. So if you're interested in a very simple, yet useful web app to analyze, see: https://github.com/alexandru/github-webhook-listener My…

Migrate your static site to Hakyll https://jaspervdj.be/hakyll/ from Jekyll, and use git subtree (http://brittanderson.github.io/posts/2018-01-17-hakyll-and-g...) to publish on GitHub Pages without Travis :)

Re: A Dead-Simple Web Stack in Haskell

#99

I think a simple web stack should aspire to the simplicity of the PHP stack, twenty years ago: 1) Create a directory "foo" on your server 2) Make a file called "bar.php" in that directory 3) Write "Hello World!" in the file 4) Open http://localhost/foo/bar.php in the browser and see "Hello World!" Lines of code or configuration so far: zero . 5) Add some actual code to bar.php 6) Reload the page and see the result Nu…

I agree that software development has become (often) pointlessly over complicated in the past few years. For my personal projects I usually develop in Yii2, vanilla JS, SCSS, on MAMP. Source lives in Git, deploy via FTP. I track my progress on a simple kanban. I can push out really complex web applications in days. At work, currently we use headless Drupal 8 as an API layer, React/Angular frontend, automated deployme…

Not software development in general but web development in particular.

My cynical take on this is that web development is relatively simple so that the 'masses' of web developers funded by the billions poured into web startups, whose products are also often relatively simple technically-speaking, need to create work.

Re: A Dead-Simple Web Stack in Haskell

#100

Let's walk through my thoughts. Hmm, okay so Spock looks nice. Neat! The routing code looks very easy to read: main = do spockCfg Hello world! " get "users" $ do Spock.json (A.object [ "users" .= users ]) get ("users" var "friends") $ \userID -> do Spock.json (A.object [ "userID" .= (userID :: Int), "friends" .= A.Null ]) Alright, let's figure out how this works. runSpock :: Port -> IO Middleware -> IO () Okay that m…

That documentation indeed could be improved, but I guess the intention here is that basic usage is learned from the tutorials. Though it's possible to figure from that documentation alone as well (I'm reading it for the first time too, but using Haskell often): Path construction collects types of arguments into xs, then HVectElim (heterogeneous vector eliminator, or maybe "elimination") unwraps it into an appropriate function type. xs are those types, ps is PathState, st usually stands for "state".

A dumb web "Hello, world!" can be written with just putStr though, using CGI (along the lines of what I've mentioned in another comment here). Or perhaps with Network.CGI ("cgi" package), which is quite a bit more straightforward than that RouteSpec, especially if one wants to quickly understand how it works.

I had a similar experience (wanting to use a language for something useful, but mostly failing to) with Rust, and maybe Python (just s/wanting/having/ in that case), but I guess the problem with that was primarily in trying to find out what's the "right"/idiomatic way to do something while there's none, or to apply practices from other languages. And maybe in not having a suitable project idea at the time. Most likely there can be more reasons of that, but they seem to go away with practice, clear goals, and/or motivation.

Post reply on HN