One of the things I think Python got right was the establishing of a WSGI (and, much later, ASGI) protocol to demarcate application from the reality of networks. Does Haskell have an equivalent? (Is it a monad?)
This is not a gateway, but you can build gateways with this. The module provides a lower-level handlers that can be divided into 4 major groups:
- Synchronous tasks: enable a full-featured language in Nginx location handlers
- Asynchronous tasks: Nginx worker's main thread do not block on waiting, fit very well IO-bound tasks
- Asynchronous services: background tasks that are not bound to client requests
- Content handlers: generate responses to client requests
Note that all of them run inside the Nginx worker process, synchronous - within the main worker's thead, asynchronous - in the lightweight threads of the Haskell runtime.
As to Monad and demarcation. The synchronous tasks are sub-divided into pure and impure tasks. Pure tasks are guaranteed in compile time to not launch missiles in run time. Impure tasks are wrapped inside the IO Monad and allowed to do whatever usual C code can do. Btw, guarantee of purity is not a virtue of Monad solely, but rather a more complex thing, e.g. hiding IO constructor does not let escape from IO. Besides IO, there are various effect systems in Haskell which let applying more constraints on the effects but they are not (yet?) used in this module.
I don’t know much about Python, but from searching up WSGI, this sounds quite similar to the Web Application Interface [https://hackage.haskell.org/package/wai].
- Synchronous tasks: enable a full-featured language in Nginx location handlers - Asynchronous tasks: Nginx worker's main thread do not block on waiting, fit very well IO-bound tasks - Asynchronous services: background tasks that are not bound to client requests - Content handlers: generate responses to client requests
Note that all of them run inside the Nginx worker process, synchronous - within the main worker's thead, asynchronous - in the lightweight threads of the Haskell runtime.
As to Monad and demarcation. The synchronous tasks are sub-divided into pure and impure tasks. Pure tasks are guaranteed in compile time to not launch missiles in run time. Impure tasks are wrapped inside the IO Monad and allowed to do whatever usual C code can do. Btw, guarantee of purity is not a virtue of Monad solely, but rather a more complex thing, e.g. hiding IO constructor does not let escape from IO. Besides IO, there are various effect systems in Haskell which let applying more constraints on the effects but they are not (yet?) used in this module.