Closed jerbaroo closed 7 years ago
Thanks! I have to admit that I'm not particularly happy that this class is necessary, but it probably can't be helped. In particular, the alternative — everybody implements their own version of MonadUI
— is definitely worse. Merged!
I'd like to mention that using liftBase
with an instance for MonadBase UI UI
from https://hackage.haskell.org/package/transformers-base is an alternative, and arguably cleaner, solution, and comes with instances for all the common transformers for free.
This is related to using a custom monad stack.
I have found using a custom monad stack useful for storing
Behavior
s, such that one part of the application can easily emit a new value, or some other part of the applicationsink
that value. Simply byask
ing for the necessary function.I also use a custom monad stack for a unique ID generator.
The problem with the approach in #161 is if I choose to edit my monad stack then I'll have to change all uses of
lift
to perhapslift $ lift
-- and usinglift
doesn't scale well with the amount of stacked monads. It's easier to make the custom monad stack an instance ofMonadUI
and useliftUI
instead oflift
, then if my monad stack changes in the future I will only have to edit the instance ofMonadUI
, instead of all the uses oflift
.