Return is an IO data constructor for a computation that has finished. It holds a value a and signals that interpretation can produce that value without performing further steps. section 13.3.1
Distinguish Return from the other computation constructors:
- Return(a) represents a completed computation whose result is a. section 13.3.1
- Suspend represents an effect that must be executed to produce a result. section 13.3.1
- FlatMap continues an existing computation by applying a function to its result and producing the next computation. section 13.3.1
Return inside map
map can be expressed through flatMap by wrapping the transformed value in Return: flatMap(a => Return(f(a))). During interpretation, a Return encountered beneath FlatMap lets the interpreter apply the continuation immediately. section 13.10
