liveBook · Manning

I/O

As explained in F# in Action: A Revised Edition of Get Programming with F#

External I/O is input or output involving a resource outside the program, such as a network service or database.

I/O is interaction with the outside world: console input and output, databases, file systems, HTTP, and other resources beyond the program. These interactions typically involve side effects and belong at the application boundary. section 15.1.1

Keep domain logic in the known world of the application. Functions can validate, transform, and pass data through the core, while boundary code receives input and produces database commands, HTTP responses, or other external effects. section 14.3.5 section 15.1.1

Treat I/O deliberately:

  • Use asynchronous programming for HTTP and database calls when waiting or scalability makes synchronous communication unsuitable. section 12.1.1
  • Push I/O toward the edges so the core can use pure functions for business logic and remain easier to test. section 14.3.5
  • Model a web request as a flow from JSON input through validation and business logic to SQL and an HTTP response. section 15.1.1
Figure 15.1 A fictional expression chain of function calls, with separation between the impure outside and (mostly) pure inner world

Use the figure to trace how impure outside interactions surround a mostly pure chain of transformations. section 15.1.1

How F# in Action: A Revised Edition of Get Programming with F# covers it

How deep it goes
Explains boundary placement and asynchronous use cases, but stops short of implementation details or type-level enforcement.
Examples
Uses HTTP requests, database calls, console interaction, file systems, JSON validation, SQL commands, and HTTP responses.
What it assumes
Assumes basic application and domain-logic concepts while teaching the separation between external effects and pure transformations.
What you can do after
Apply it via boundary-oriented design that keeps business logic pure and makes asynchronous external work explicit.
How it connects
Connects I/O with asynchronous programming, pure functions, side effects, domain logic, Ports and Adapters, Hexagonal architecture, and Onion architecture.

Also explained in

Compare how 4 books explain I/O →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of F# in Action: A Revised Edition of Get Programming with F#. The section links point to the parts of the book it draws on.