
Ask HN: Separate Logic from IO - truth_seeker
In functional programming, to what extent it is practical to separate Logic from IO ? How to combine them effectively ?
======
mindcrash
In some cases it is very practical, even in other (non functional) programming
languages.

For example, [https://sans-io.readthedocs.io/](https://sans-
io.readthedocs.io/) (and its accompanying talk
[https://www.youtube.com/watch?v=7cC3_jGwl_U](https://www.youtube.com/watch?v=7cC3_jGwl_U))
give some really great brainfood about the way currently all kinds of network
protocols are implemented, and the benefits of separating the protocol (Logic)
from the actual implementation (IO).

You might also want to query Google or DDG for "Free monads" if you want to
implement a similar layered approach in a functional language such as Scala or
Haskell.

~~~
truth_seeker
That's very concise. Thanks. Always good to see actual code :)

------
itamarst
It's fundamentally necessary, since I/O is stateful. Functional languages have
language-specific ways of doing this, but you can see examples of this in non-
functional languages.

[https://www.destroyallsoftware.com/talks/boundaries](https://www.destroyallsoftware.com/talks/boundaries)
is a great, practical talk about this.

~~~
truth_seeker
Great talk! Thanks for sharing

