Closed turion closed 2 years ago
Do you want to have MaybeT
treated in the same way? It would make sense, I guess.
Do you want to have
MaybeT
treated in the same way? It would make sense, I guess.
That sounds good but it may be best to finish the ExceptT
story first.
Please ping me when this PR is good to review!
Do you want to have
MaybeT
treated in the same way? It would make sense, I guess.That sounds good but it may be best to finish the
ExceptT
story first.
Yes, agree. I wanted to upload this first stub so you can see the direction we're heading.
Do you want to have
MaybeT
treated in the same way? It would make sense, I guess.That sounds good but it may be best to finish the
ExceptT
story first.Yes, agree. I wanted to upload this first stub so you can see the direction we're heading.
My expectation is that MaybeT
will be just like ExceptT
with e = ()
, but sure feel free to share the first stub if you like!
Do you want to have
MaybeT
treated in the same way? It would make sense, I guess.That sounds good but it may be best to finish the
ExceptT
story first.Yes, agree. I wanted to upload this first stub so you can see the direction we're heading.
My expectation is that
MaybeT
will be just likeExceptT
withe = ()
, but sure feel free to share the first stub if you like!
Oh yes, I believe that as well. I rather meant that I wanted to share this PR here with this one file before I go on working everything out, since it contains the essential motivation for doing all that work.
Sure, sounds good!
I don't know why I didn't mark it as ready for review. I believe it is.
Ah, deriving MonadFail
of course doesn't work for older GHCs. What's your policy for these situations? Deprecate older GHCs? Don't derive MonadFail
? CPP?
Ah,
deriving MonadFail
of course doesn't work for older GHCs. What's your policy for these situations? Deprecate older GHCs? Don't deriveMonadFail
? CPP?
If it's just about MonadFail
, then let's just write the instance by hand.
Could you test this transformer somehow? We do have a little testsuite for checking all Selective laws of various instances.
Could you test this transformer somehow? We do have a little testsuite for checking all Selective laws of various instances.
Yes, I'd replicate the Writer
test suite and adapt it.
But there is a problem: Where to put the Arbitrary
instance for ExceptT
? Putting it in the tests is an orphan instance. Also we would probably like to make the instance public so others can use it in their tests as well. But we don't want QuickCheck
as a dependency to the main library.
I know two typical solutions to this situation:
arbitrary-instance
that conditionally activates the QuickCheck
dependency. This flag is default false
and can be set true
for packages that want to test ExceptT
(such as the test suite)I like the second option more.
Ah, we have to add an orphan instance for transformers
' ExceptT
anyways.
I went for the first option for the time being. Are there any extra laws that make sense checking for ExceptT
?
It becomes more cumbersome to derive instances:
MonadFail
wasn't re-exported from Control.Monad
in older GHCs, that's why older pipelines fail. If I explicitly import it, I get an unused-import
warning on newer GHCs.Data.Functor.Contravariant
doesn't exist in GHC < 8.6 (or rather the corresponding base).Again the question what to do. Some options:
MonadFail
and Contravariant
I personally like 1. by far the most. But of course the choice is yours.
@turion Apologies for the long silence! I somehow missed the notifications.
While I don't mind dropping compatibility with older GHCs in principle, doing this just to support MonadFail
and Contravariant
instances doesn't seem great. Let's just omit these instances for now. I doubt anyone will notice, to be honest :)
Are there any extra laws that make sense checking for
ExceptT
?
I'm not aware of any.
Orphan instance in tests
Yes, this is fine. Thanks!
Ok, then I think I've done everything :)
The build failure is caused because except
used to have the type Either e a -> Except e a
which changed to Either e a -> ExceptT e m a
at some point. Older GHC versions somehow require older transformers
versions indirectly. Again I'm not sure how to proceed. We can do CPP to have two definitions depending on GHC versions, drop Control.Selective.Trans.Except.except
, or drop older GHCs.
The build failure is caused because
except
used to have the typeEither e a -> Except e a
which changed toEither e a -> ExceptT e m a
at some point.
Ah, that's unfortunate. Let's use CPP to match the type for older GHC versions.
If we already have CPP, shall I re-add MonadFail
and Data.Functor.Contravariant
?
If we already have CPP, shall I re-add
MonadFail
andData.Functor.Contravariant
?
Sure, let's do that. Thanks!
If we already have CPP, shall I re-add
MonadFail
andData.Functor.Contravariant
?Sure, let's do that. Thanks!
Looks like it may be harder than it seemed. Feel free to skip this bit if you like!
@snowleopard I could figure it out in the end. Ok like this? Then I'll squash.
Awesome, many thanks! I've squashed the commits.
I think it's a pretty cool new module :) I'll try to release a new version of the library soon.
Awesome, this was great fun :)
I just realised (again?) that the ExceptT
instance is just the one from composing with a Traversable
https://github.com/snowleopard/selective/issues/12#issuecomment-884793429 I believe. So in the long run I think we should define another newtype plus instance for the general case and derive Selective
that way.
Also, was it really necessary to delete the old transformers instance? It's more restrictive than this one, but still it doesn't do any harm, right?
Agreed with both points! It would be cleaner to reuse a general Traversable
based implementation in the ExceptT
instance. And the old instance can remain, perhaps with a comment pointing to the existence of a less restrictive instance.
This implementation of ExceptT has an Applicative instance that does not need a Monad constraint of the underlying context.