-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure to automatically derive classes with operators #26
Comments
I admit I don’t totally grok what you’re trying to do here. It doesn’t make much sense to me as to why you would want to stub out But yeah, the list of classes you supply to |
Well, I only need I just got attracted in that direction since writing something like
Seemed wrong (even though it compiles just fine) Actually, I'm not even sure if I should define instances on Thank you again for your work on this library and the quick replies :) |
So, yes, if you want to define your own instances, defining them on What does your monad transformer stack look like, exactly, and how are you defining those instances? Are you using the |
Sure, I actually realized that indeed I probably don't want a MonadPlus instance, since
I used to define the MonadPlus instance like this:
but now I'm trying to understand why do I actually need a MonadPlus instance for TestFixtureT in this kind of code: https://gist.github.com/berdario/394ca0be1ecbde9f057612e1c5dc9740 (again, this might be a trivial doubt... I just haven't had the time to think properly on it) |
Yeah, I’m sort of unclear why you’re using |
Since infix operators cannot contain underscores, use a tilde instead when generating fixture record names for infix operators. fixes #26
…on for classes with infix operators (#27) * Add tests for the TH code on GHC 8 using th-to-exp and test-fixture * Support fixture generation for classes with infix operators Since infix operators cannot contain underscores, use a tilde instead when generating fixture record names for infix operators. fixes #26
If you try to
You'll get the following error:
This error is quite obvious, and in my case I needed an Alternative instance, because I wanted my TestFixture to be an instance of MonadPlus
In turn, I wanted to use MonadPlus instead of MaybeT, to avoid having a concrete transformer stack to juggle.
I got the MaybeT in my code from Haskeline, and I solved this issue like this:
Just like in the other issue I opened, it seems a common pattern that sometimes trying to directly reuse/implementing an existing class might turn out to be cumbersome, and the best way to encode effects and selectively define testfixture instances for them would be to instead define my own classes, and add thus a layer of indirection. Do you think this is truly the best approach?
Obviously I could also try to define my own instance of Alternative for TestFixture, but it feels icky to define an instance for a type that is not even defined in the source code (when using TH)... and I thought that I was going down the wrong path.
OTOH now I'm thinking if I should reconsider this choice, since I now got a need to use
mzero
as the result of a TestFIxture instance function, and this would obviously imply having a MonadPlusThe text was updated successfully, but these errors were encountered: