Hey y’all. I know Ethereum may not be of general interest in our community, but the purescript Ethereum libraries that my friend and I maintain are (imo) pretty great anyway. The whole suite just got a major face lift for 0.15 and just thought I would share them here (see links at bottom).
Even if you don’t care about Ethereum at all, these library pull together many advanced parts of the ecosystem all in one place which you might find useful as examples in your own work. We started these libraries in Purescript 0.10 and it’s unrecognizable how much more robust it is today with all of the libraries and language features we have at our disposal.
Some highlights in case you are interested:
- tidy-codegen: much of the core utility in ethereum libraries is being able to easily to use FFI with smart contracts. We make heavy use of tidy cogeden to generate the purescript code from the Solidity compiler output.
- type level ints: The codecs for ethereum (i.e. ABI encodings) make a lot of use of whether a type is dynamically or statically sized. In the case of statically sized types (like the size of the uint, int, vector, bytes, etc) we use type level ints to index the corresponding purescript types. This also helps with the FFI generation – size indexed args appearing as function args help you not mess up something important.
- quickcheck and quickcheck-laws.There are A LOT of possible things you might want to encode/decode and using quickcheck to avoid missing those is crucial. Also, because we don’t want to have to write a quickcheck test for every sized type, we can use some clever tricks to get around this.
- purescript-heterogeneous: This library allows us to solve some highly annoying and ethereum specific problems when it comes to listening for events that are logged by smart contracts. I’m not going to go into detail unless someone wants, but suffice it to say the type signatures are longer than the implementations on these ones
There are additional interesting parts, but I’ll stop there. Here are the repo links: