f-o-a-m / purescript-web3

a purescript library for the web3 api
Apache License 2.0
127 stars 24 forks source link

Add `Newtype` derivation to `Block` #53

Closed XertroV closed 6 years ago

XertroV commented 6 years ago

Since we don't have lenses on Block fields a Newtype instance let's us use unwrap and the like.

Not sure if we had this before or not, but noticed it was missing now.

martyall commented 6 years ago

we don't really use that anywhere (transaction, receipt, etc). maybe we should include instances for all such objects if we have it for one

XertroV commented 6 years ago

maybe we should include instances for all such objects

Yup - agreed. It's not used in the library but I definitely use it - I prefer block <- unwrap <$> runWeb3 ... to (Block block) <- runWeb3 ... and the like. Just makes it a bit more flexible.

I'll add in Newtype derivations to other types tomorrow.

XertroV commented 6 years ago

@blinky3713 - Added the rest of newtype derivations

Other changes:

Only types we don't have newtype derivations for are stuff like HexStrings (where there are good reasons for not letting people wrap and unwrap, etc)

XertroV commented 6 years ago

@blinky3713 - FYI added some tests for newtype derivations to make sure they aren't removed (I think I added at least some of them before that got removed once).

Anyway, I'm not sure sure how best to test for derivations - basically here I just rely on the typechecker and throw away the result of any web3 computations (so it doesn't matter if a node is running or not)

If you have any better ideas please let me know.

martyall commented 6 years ago

🎉