Comments (14)
If that suits your needs, why not?
from cooked-validators.
There's pretty-printing for UtxoState
, though, which we could use to implement Show
. Probably Show
was deepened unnecessary after we implemented pretty printing?
from cooked-validators.
So should we use the prettyCooked
instance for Show as well?
from cooked-validators.
This is intended. In the end the plan is to remove requirements about Show
instances for datum and redeemers (we already require PrettyCooked
). So UtxoState
will no longer be showable. Also, implementing Show
from Pretty
/PrettyCooked
does not seem, if I am not mistaken, in the philosophy of what Show
is usually expected to be: a raw printing of information. The pretty printing, on the other hand, takes liberties when it comes to printing, it omits info on purpose, etc. Besides, for your use case, in a repl, pretty-printing has upsides: for example it will adapt to your window size and line break when necessary while a conversion to string will blindly assume 80col-long lines.
I think this may be related to #234 in a way. Solving #234 would probably be the occasion to introduce some wrapper function or PrettyCooked
instance to introduce convenient runAndPrettyPrint
functions to use during experiments in the REPL
from cooked-validators.
if I am not mistaken, in the philosophy of what Show is usually expected to be: a raw printing of information
This is my opinion too, using pretty
for Show
seemed a bit strange to me. But how should I solve my problem? Is there a way to use the pretty
function in the repl?
from cooked-validators.
You can use putDoc
from Prettyprinter
from cooked-validators.
How can I convince the repl to use putDoc
?
from cooked-validators.
By default Doc a
, so DocCooked
as well, are showable so you should see something if you just prettyCooked
.
Alternatively, import Prettyprinter
and putDoc . prettyCooked
.
from cooked-validators.
I'm afraid I can't make things work out, could you tell me precisely how I should modify my snippet above to make it work?
from cooked-validators.
I see what you meant: but prettyCooked
cannot work right away because the value returned is an Either ... ...
, so this doesn't have any prettyCooked instance.
from cooked-validators.
There is prettyEndState
in Pretty.Cooked
. I could introduce a prettyRunResult :: Show a => PrettyCookedOpts -> (a, Either MockChainError UtxoState) -> DocCooked
if you want. We already have pretty printing functions for state and mock chain error.
from cooked-validators.
Why not, but actually I'm more interested in knowing whether you think the behaviour I described in this bugreport is the expected one, or whether you think it's a bug.
from cooked-validators.
The "bug" being
cabal repl fails upon evaluation of some data of type
Either ... UtxoState
from cooked-validators.
I think it is expected since UtxoState
is no longer showable. The repl implicitly requires the returned value to be showable in order to print it. It does the same when evaluating any non Show
able value.
It is now a matter of whether (and how) we want to restore an instance of Show for UtxoState
.
In my opinion we should not for the reason I talked about above:
- We have what we need to pretty print stuff better than what we would have using
Show
, we just lack wrapper functions in the user-facing API (see #234). @carlhammann and I plan to refresh theTesting
module that has remained the same since V1. This would be the occasion to introduce functions dedicated to tinkering in the repl: they would run a mockchain and pretty print the result (IO ()
) in addition to current functions that are expected to be used in test trees. - Basing
Show
onPretty
is not really whatShow
is about - Deriving
Show
would require datums to beShow
able, which is currently the case but actually no longer relevant because they must implementPrettyCooked
too.
from cooked-validators.
Related Issues (20)
- Get rid of the hack to retrieve private keys in `Cooked.Wallet.walletStakingSK`
- Pre commit hook failure HOT 4
- CI does not catch issues on `examples`
- Export lists for modules HOT 6
- Qualifying imports HOT 1
- Reporting code coverage
- Newline with `printCooked` HOT 1
- Time weirdnesses in `plutus-ledger-api` and `cardano-ledger` HOT 1
- Peculiar behaviour of GitHub Actions caches with respect to pull requests HOT 1
- Add a function to test for specific tokens and wallets on the final ledger state
- Formatting descrepancy between flake check and development shell
- Factor out the "combining modifications" idiom
- Fee probing
- Can't pay freshly minted `quickValue`s / can't work with Plutus V1 minting policies (?) HOT 1
- Make our development environment not depend on Ormolu 0.5.0.1
- Bump GHC version to 9.2.7
- Improving PrettyCooked with additional hash-to-name feature
- Generalize initial distribution
- Improve test coverage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cooked-validators.