6 ms·
Rolling Your Own Blockchain in Haskell
- lambdaxdotx 9y agoHere is another "minimum viable" blockchain implementation in Haskell: https://github.com/adjoint-io/nanochain https://github.com/adjoint-io/nanochain. It's a bit simpler in implementation; the relevant data structures are defined a bit differently, so it could give a nice alternate perspective about what a blockchain written in Haskell may look like.
- umen 9y agoGreat stuff , where can I learn about blackchain in begginers level with code examples ?
- imdsm 9y agohttps://news.ycombinator.com/item?id=14659775 https://news.ycombinator.com/item?id=14659775
- cyphar 9y agoIt's quite a cute idea, implementing a blockchain (a fundamentally impure concept) in Haskell. If you're interested in other cool Haskell projects, check out JoeyH[1]. [1]: http://joeyh.name/code/ http://joeyh.name/code/
- Kinnard 9y agoWhat do you mean by a 'fundamentally impure concept'?
- quickthrower2 9y agoNot the OP but maybe he means there are side effects. Of course Haskell can side effects that is one of the big misconceptions.
- cyphar 9y agoImpure as in "has side-effects". An append-only state that is used for synchronisation between different machines by definition has side-effects. Of course, you can have side-effects in Haskell, I just thought it was an interesting choice.
- tree_of_item 9y agoHaskell takes a stand against implicit side-effects, letting you see what a function is capable of doing in its type. It's really weird to suggest that performing side-effects in such a language is strange or awkward or cute or whatever. Doing those things is the whole point of writing programs.
- arianvanp 9y agoSeems a fundamentally pure concept to me. Writing down facts that never change in append-only fashion.
- alphaalpha101 9y agoI like the idea behind this article, but this isn't the way to do it. It hides the simplicity of the blockchain concept behind arcane syntax and overly complicated higher-order typing constructs. newtype BlockF a = Block (V.Vector a) deriving (Eq, Show, Foldable, Traversable, Functor, Monoid) type Block = BlockF Transaction type Blockchain = Cofree MerkleF Block Does anyone really think this is how one should write software? I think that constructions like Cofree are interesting, but I don't think they're programming.
- WmyEE0UsWAwC2i 9y agoIt depends on the reader's amount of "vocabulary". Why write more complicated code if it is just Cofree? DRY. OTOH, how many elements should the reader's vocabulary have to enable him to read other's people code?
- mixedCase 9y agoFrom https://hackage.haskell.org/package/free-4.12.4/docs/Control-Comonad-Cofree.html https://hackage.haskell.org/package/free-4.12.4/docs/Control... : "A Comonad v is a cofree Comonad for f if every comonad homomorphism from another comonad w to v is equivalent to a natural transformation from w to f. A cofree functor is right adjoint to a forgetful functor. Cofree is a functor from the category of functors to the category of comonads that is right adjoint to the forgetful functor from the category of comonads to the category of functors that forgets how to extract and duplicate, leaving you with only a Functor." So I take it you believe that a degree in category theory is the bare minimum for people to expect to be able to understand other people's code? The layman interpretation of "Avoid success at all costs" comes to mind.
- phillipcarter 9y agoAlthough I don't disagree regarding the difficulty of understanding Cofree, at least the blog post explains what it's doing in this context. That alone was enough for me to understand that beginning snippet, convince me that there was at least some utility in the use of Cofree here, and remember this as an example of where it can be useful. The parent^2 comment also snipped an example explained in the blog post, where he specifically chose that structure so that he could make use of built-in structures to traverse the tree. Similar to the use of Cofree (though I understand the Traversable monad far more), the reasoning was presented, it made sense, and I could move on from that without scratching my head.
- macsj200 9y agoInitially read submission site as malbolge.us
- ngcc_hk 9y agoany other language? Python and lisp would be interesting.
- Narhem 9y agoPython: https://github.com/llSourcell/The_Power_of_the_blockchain/blob/master/blockchain.py https://github.com/llSourcell/The_Power_of_the_blockchain/bl... Relevant video: https://www.youtube.com/watch?v=LZEHOlZY2To https://www.youtube.com/watch?v=LZEHOlZY2To
- qaezel 9y agohttps://github.com/input-output-hk/cardano-sl https://github.com/input-output-hk/cardano-sl