Closed cdepillabout closed 7 years ago
Hmm, after playing around with it a little bit, I couldn't figure out a way of defining the instance MonadBaseControl IO (ActionCtx ctx m)
that doesn't require UndefinedInstances
. Looks like (2) isn't really a viable option. We should probably go with either (1) or (3).
I'd say UndecidableInstances
should be okay here. I think a great thing would be to write a small unit test to make sure that the instances are usable and work as advised. Then we can merge :-)
Okay great, I'll add some tests.
BTW, I was wondering about UndecidableInstances
, so I submitted a question to the Haskell reddit. Edward Kmett gave a nice long reply explaining when UndecidableInstances
is safe and when it is dangerous.
tl;dr It's basically safe in the case of MonadBase
and MonadBaseControl
.
Tests have been added in commit 5e38734.
The tests are somewhat contrived, but they do test the functionality provided by MonadBase
, MonadBaseControl
, and MonadTransControl
.
Great, thanks! :-) Will merge when green 👍
This PR adds an instance of
MonadTransControl
,MonadBase
, andMonadBaseControl
forActionCtxT
. This closes #116.Commit 0aa24d4 adds an instance of
MonadTransControl
forActionCtxT
. Aside from some hairy wrapping and unwrapping, it is pretty straight-forward.Commit 9d83386 adds an instance of
MonadBase
andMonadBaseControl
forActionCtxT
. The main problem with this is that it requiresUndecidableInstances
.Here are three different courses of action I feel like we could take:
Just merge in this PR.
monad-control
andtransformers-base
both useUndeciableInstances
when defining their instances ofMonadBase
andMonadBaseControl
for the standard transformers likeExceptT
,ReaderT
, etc. If it's good enough for them, it's good enough for us.Realistically, it's unlikely that a user would want to define an alternative instance of
MonadBase
orMonadBaseControl
forActionCtxT
.Right now, the
MonadBase
andMonadBaseControl
instances look like this:Trying to compile this without
UndecidableInstances
produces the following warning:If we heed the warning, we could define specific instances of
MonadBase
andMonadBaseControl
forIO
. It would look something like this:This means there won't be an instance of
MonadBase
andMonadBaseControl
for users runningActionCtxT
in some other base monad (likeST
orMaybe
). But realistically, there probably aren't many users that actually do that. And even if there are, it's unlikely that they also want to useliftBase
,liftBaseWith
, andrestoreM
.Don't provide
MonadBase
orMonadBaseControl
instances, but export the constructor forActionCtxT
. That would let users write their ownMonadBase
andMonadBaseControl
instances.We could still provide the
MonadTransControl
instance from commit 0aa24d4, since it doesn't requireUndecidableInstances
.@agrafix Let me know what you think about these three options.