Hi Rouan,
I recently developed the effective-aspects package [1], which is a library for monadic pointcut/advice aspect-oriented programming (AOP) in Haskell. Essentially we keep track of the aspects (handlers if you think in terms of event-based programming) in a pure state monad.
My problem is that the publish method returns IO (), which means that events can only be
published from the IO monad, but I would like events to be 'publish-able' from pure code.
In the library, you must define a monad with the AOT transformer on top, say
type M = AOT IO
type M' = AOT (StateT String (ErrorT String Identity))
...
Our model is not tied to the IO monad (rather to an 'AOMonad' class that provides weaving); hence it does supports pure events (join points in AOP terminology). A pseudo-code example is:
-- foo has type A -> m B for some types A, B and monad m
-- adv has type Advice (A -> m B); which is a type synonym for (A -> m B) -> A -> m B
do (deploy (aspect (pcCall foo) adv))
foo # arg
here the # is the 'open application' operator, which triggers the weaving process that eventually executes the advice.
I think your particular use case is not described in your email, but if you want to expose some content other than the application's arguments it will need some small work on my part (and a new version of the library). I will be pleased to help you if you are interested in using the library, and if you can wait a little--- I'm really time-constrained this month :)
Bests,