4 ms·
Ask HN: Separate Logic from IO
In functional programming, to what extent it is practical to separate Logic from IO ? How to combine them effectively ?
- itamarst 9y agoIt'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 9y agoGreat talk! Thanks for sharing
- mindcrash 9y agoIn 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 9y agoThat's very concise. Thanks. Always good to see actual code :)