Abstract:
The structure of monadic functional programs allows the integration of many different features into such programs by just changing the definition of the monad and not the program, which is a desirable feature from a software engineering and maintenance point of view. We describe an algorithm for the automatic transformation of a function into such a monadic form. We argue that the proposed transformation is sound and under certain conditions also complete. We also show how invertible monads can be used to extend the scope of the proposed transformation and can help to prevent the proliferation of monads over a program.