this post was submitted on 15 Feb 2024
10 points (100.0% liked)
Functional Programming
1398 readers
1 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
True Functional Programmers will probably correct my lack of nuance here, but my understanding is that the IO monad is basically just scribbling some category theory formalities on top of IO ops so that everything is still technically a pure function. You can think of the IO monad as representing the "state" of the rest of the universe outside of your program, which your program reads or modifies. As you pass through your monadic bind ops (i.e., as you read or write IO), the state is carried through implicitly and "modified" as appropriate. All functions, then, are just transforming data (i.e., either your program's data or the rest of the universe), so everything is pure.