I've just been investigating FRP in Haskell (mainly reactive-banana
(testimonials!)), and I'm wondering is it common for them, and in case of reactive-banana what's the reason to operate in IO
monad instead of being constrained to MonadIO
, or rven better, any Monad
(so that I could provide own stack)?
It seems to me that's because of focus on GUI programming, where you integrate it with some existing libraries that operate in IO
? Would it be feasible to change it so that I could integrate it with custom monad stack?
If you are asking why
reactimate :: Frameworks t => Event t (IO ()) -> Moment t ()
expects an event with values of type IO ()
instead of allowing for a custom monad M ()
with instance MonadIO M
, then the answer is this:
In practice, custom monad stacks only add state/reader/writer effects to the base IO
monad. However, in theory, it is entirely possible to add fancy control mechanism like coroutines or non-determinism. I don't know how to integrate the internal state arising from combinators accumE
with these more general effects, and I have no idea what it means for an event to happen in a non-deterministic context. That's why reactimate
is restricted to IO
.
If you have a custom monad stack that is of the state/reader/writer family, then it is usually possible to map it to a pure IO
computation and use this with reactimate
. If you find that this doesn't work out (I do think that there might be a problem), I would need a more detailed description of the concrete situation to be able to help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With