-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve output of generrors #551
Conversation
99e712a
to
aa785eb
Compare
Commit 4659a61 fails with the following type-check error: HSTransactionStructure != ⊤ of type Type
when checking that the pattern KeyHashObj x has type
Ledger.Address.Credential
(Ledger.Types.Epoch.GlobalConstants.Network
(TransactionStructure.globalConstants HSTransactionStructure))
(Ledger.Crypto.isHashableSet.THash
(Ledger.Crypto.Crypto.khs
(TransactionStructure.crypto HSTransactionStructure)))
(Ledger.Crypto.Crypto.ScriptHash
(TransactionStructure.crypto HSTransactionStructure)) at the fourth line of the following code block from -- Since the foreign address is just a number, we do bad stuff here
Convertible-Addr : Convertible Addr F.Addr
Convertible-Addr = λ where
.to → λ where (inj₁ record { pay = KeyHashObj x }) → x
(inj₁ record { pay = ScriptObj x }) → x
(inj₂ record { pay = KeyHashObj x }) → x
(inj₂ record { pay = ScriptObj x }) → x
.from n → inj₁ record { net = _ ; pay = KeyHashObj n ; stake = KeyHashObj 0 } |
(inj₁ a) → sep + " ¬ ( filterˢ isKeyHash (mapˢ RwdAddr.stake (dom wdrls)) ⊆ dom voteDelegs ) " | ||
+ sep + " filterˢ isKeyHash (mapˢ RwdAddr.stake (dom wdrls)): " | ||
-- + show (filterˢ isKeyHash (mapˢ RwdAddr.stake (dom wdrls))) | ||
+ show (dom wdrls) | ||
(inj₂ b) → "¬ ( mapˢ (Bifunctor.map₁ Bifunctor-× (RwdAddr.stake)) (wdrls ˢ) ⊆ proj₁ rewards )" |
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 approach can go out of sync when somebody changes the order of predicates. I think it's fine to use genErrors
and then just append all of the debug information regardless of which rule fails.
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.
Yes, the error messages don't have to be all that readable, they're just for us. And not having to maintain them is a big plus. Just doing some super basic postprocessing of the generated strings to get rid of the fully qualified names also goes a long way in improving readability.
I think that when you try to use the |
src/Ledger/Address.lagda
Outdated
@@ -22,7 +23,8 @@ credential contains a hash, either of a verifying (public) key | |||
ScriptHash | |||
\end{code} | |||
\begin{code}[hide] | |||
: Type) ⦃ _ : DecEq Network ⦄ ⦃ _ : DecEq KeyHash ⦄ ⦃ _ : DecEq ScriptHash ⦄ where | |||
: Type) ⦃ _ : DecEq Network ⦄ ⦃ _ : DecEq KeyHash ⦄ ⦃ _ : DecEq ScriptHash ⦄ | |||
⦃ _ : Show Network ⦄ ⦃ _ : Show KeyHash ⦄ ⦃ _ : Show ScriptHash ⦄ where |
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 wouldn't add the Show
instances as module parameters since they're only needed for defining other Show
instances. It'd be better to move these parameters to the Show
instance definitions that are actually using them.
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.
Yeah. Might be worth considering doing the same for DecEq
, but there might be some stuff that requires it that isn't some other DecEq
instance in which case I think this might be cleaner.
No, it's something much weirder. This error message is in the pattern and the instances actually get fully resolved somewhere earlier, so Looks like it could be an Agda bug to me, especially because the first thing I tried when playing around with this triggered an |
Oh, no, it's actually what you said. If you add I still don't understand why this happens though. |
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.
So there is a lot of work involved in making Show instances in Agda.
These will probably come in handy in the future as well.
= KeyHashObj Integer | ||
| ScriptObj Integer | ||
deriving (Show, Eq, Generic) | ||
#-} | ||
data Credential : Type where | ||
ScriptObj : Hash → Credential | ||
KeyHashObj : Hash → Credential | ||
{-# COMPILE GHC Credential = data Credential (ScriptObj | KeyHashObj) #-} | ||
ScriptObj : Hash → Credential | ||
{-# COMPILE GHC Credential = data Credential (KeyHashObj | ScriptObj) #-} |
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.
Ah ... The culprit has been found!
* experiment with manipulating a specific error string * fix string add * add Show instances for Credential and Set and ℙ * add Show instances for more Ledger types * fixed broken type class application * incorporate suggestions from PR review and improve fail messages * Fix order `KeyHashObj` and `ScriptHashObj` constructors in the FFI --------- Co-authored-by: whatisRT <[email protected]>
Description
This will address issue #546.
Checklist