- purity is a syntactical property of programs, more precisely defined as referential transparency: replacing an expression for its bound value doesn't change meaning (precise definition)
- side effects are things that break referential transparency (precise definition)
- There's no direct connection between the concepts of IO, State and so on, and side effects. Traditionally, these things are side effectful (break referential transparency), but you can have abstractions that are pure (don't break ref.trans.)
- Due to the above, the term purely functional programming is not an oxymoron, it makes perfect sense.
- In haskell style pure FP, type constructors and algebras are used to represent "things that would otherwise traditionally be side effects (break ref.trans.)". We call these F[_]s effects or computational contexts for brevity. You can see for yourself how this cannot be a precise definition (especially because they could also have kind higher than * -> *, even though most famous a
In Pull[F, O, R]
, R
is the return type. Pull
represents a computation that emits some values on the Stream (of type O) and returns a new thing (R). In order to convert a Pull to a Stream, R must be Unit. This is because an FS2 Stream does not have the ability to terminate with a return value.
See here for the conversation
Stream[F, O]
is monadic over O which are the output values emittedPull[F, O, R]
is monadic over R which is used for stateful transformations