-
Notifications
You must be signed in to change notification settings - Fork 7
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
Adding errors to actions to help negative testing #58
Conversation
@abailly-iohk any input on this would be welcome. |
6d9582f
to
42b4f55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a significant (eg. breaking) change the advantages of which are not clear to me: From the RegistryModel
I don't see what the added complexity in additional type parameters and mandatory Either
results improves in the DX. It seems the only significant change is in the postCondition
and postConditionOnFailure
implementations and the added value does not seem to be worth the effort to my eyes.
Is there a model somewhere, perhaps in Plutus land, where this way of "first-class" handling of errors would be more beneficial?
The mandatory
Yes, this is the idea. The point is that in the case where there can be errors in the model you can add those errors without having to clutter the model with the possibility of error. The whole point is that actions can fail but that failure shouldn't appear in the model - so
Well, the effort has already been made 😅 and the migration guide is basically "add
There are examples in djed that we can't show yet. But let's do a hypothetical example. You have some action |
Well, if this ship has sailed already, then no need to wait for me :) |
42b4f55
to
96ee628
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about having an ActionError s
associated type family instead of an additional type parameter? Seems to me the blast radius of the change would be smaller and in general more consistent with the overall approach we have so far followed. WDYT @MaximilianAlgehed ?
@abailly-iohk I'm off for the next ~2 weeks so I'll let @UlfNorell handle this. |
But without having tried ut our thought about it I think it sounds like a good idea! |
Great, I will give it a shot as I might have some bandwidth available for the rest of the week :) |
I had a quick stab at replacing class' type variable with an associated type-family but did not go far yet. Will try again today. |
We had a go at the associated type and it seems to work quite well. Now you don't get the Either in perform unless you have defined an error type. Some documentation still todo. |
@abailly-iohk what do you think about this now? |
`Either SomeException ...` types
9c358af
to
28a4965
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way this is now done much more, thanks for taking into account my suggestion. Minor comments left which could be addressed later.
Adding errors to action types makes it easier to build clean models that deal with negative testing by allowing you to clearly distinguish the failing and correct cases. The thing I'm not yet happy about is having to sprinkle
Right
s in the results. Suggestions welcome!Checklist: