3 ms·
For the most part, it is possible to remodel applications to handle stateful things outside of the main program. Consider a website. An entire website can be m
by romaniv 11y ago
For the most part, it is possible to remodel applications to handle stateful things outside of the main program.
Consider a website. An entire website can be modeled as a function that takes headers, URL and request body as parameters and returns headers and body as the response.
You can use the same principle to model almost anything. You take real inputs as inputs and output instructions for imperative side-effect to a minimalist agent of some sort.
- djur 11y agoOnly static and very basic dynamic websites can be modeled that way. Most dynamic websites handle requests which are intended to have an effect (POST, PUT), which requires your function to be impure or to model state changes (DB updates, file I/O, etc.) in some way like Haskell's monads. And what that looks like is going to be much, much different from anything developers are used to in impure languages.
- romaniv 11y agoDatabase and file updates can be treated as a part of page's output.