Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard web server interface equivalent to WSGI/Rack for Haskell

There are (de facto) standard web server interfaces for programming languages e.g. WSGI for Python, Rack for Ruby. Is there the equivalent thing for Haskell? I found two trials, Hack and HSGI, but am not sure which of these (or another one) is more popular in Haskell land.

Waiting for Haskell gurus’ advices!

like image 615
minhee Avatar asked Oct 09 '11 00:10

minhee


People also ask

Is Wsgi only for Python?

The Web Server Gateway Interface (WSGI, pronounced whiskey or WIZ-ghee) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, version 1.0. 1, is specified in Python Enhancement Proposal (PEP) 3333.

What does a WSGI server do?

WSGI stands for "Web Server Gateway Interface". It is used to forward requests from a web server (such as Apache or NGINX) to a backend Python web application or framework.

What web server is used for Python?

Apache HTTPD and nginx are the two common web servers used with python.

What is the best web server for Python?

The Apache HTTP Server has been the most commonly deployed web server on the Internet for 20+ years. Nginx is the second most commonly used server for the top 100,000 websites and often serves as a reverse proxy for Python WSGI servers.


2 Answers

The de facto standard for Haskell is the WAI (Web Application Interface). It is supported by the popular Haskell web framework Yesod, and there are several packages built around this interface available on Hackage.

like image 159
hammar Avatar answered Oct 02 '22 15:10

hammar


It is widely agreed that there are currently three major Haskell web frameworks: Happstack, Yesod, and Snap (in chronological order). Each framework has its own web server. There have been attempts at other web servers, but none of them seem to have gotten off the ground. Happstack is planning to change web servers sometime soon (probably to Warp, which Yesod uses). So this leaves us with two modern mainstream web servers in Haskell: Snap and Warp (also chronological order).

Warp conforms to the interface defined in the wai package, which seems to be an attempt at defining a standard web server interface. However, WAI is used by only one of the current mainstream Haskell web servers, so I simply don't see how one can make a compelling argument that it is a genuine standard. The marginal benefit you get from being a standard is only useful when the standardized players are actually differentiated, and in the case of Snap and Warp, I'm not convinced that they are. The only thing I can think of that differentiates Warp and Snap is that Warp has posted better performance than Snap for a simple pong benchmark. But I've never heard anyone complain that Snap is too slow, so Warp's speed doesn't seem to really differentiate it.

Furthermore, WAI came out before either Snap or Warp existed. When Snap came out, we had different opinions about how the interface should look which made WAI inappropriate for us. WAI has also evolved since then, which further supports the argument that it was premature. After all, what good is a standard if it keeps changing?

If there is an explosion of new Haskell web servers with all kinds of different features and innovations, then I'm sure commonalities would emerge from which a genuine standard could be developed. But until then, I think the choice of web server is fairly insignificant. Both Warp and Snap are good web servers and shouldn't play a significant role in the much bigger choice of which framework you use.

like image 39
mightybyte Avatar answered Oct 02 '22 16:10

mightybyte