If I have a value a: Free[Op, A], is it possible to "flatten" the structure of a so that two Ops that are bound together by the free monad may be collapsed into one?
Context: I'd like to perform this as an optimization step before interpretation because a semantic of Op is that its operations are idempotent. So if two appear "in a row", the second can be eliminated at no cost to the semantics of the program.
Free'sflatMapto prevent stack overflow: it makes further introspection progress impossible by wrapping a computation into trampoline function. - P. Frolov