module Data.Apart.Usage.Blockchain
(Transaction (..), Block, Blockchain, genesis, block, mainchain, verify) where
import "free" Control.Comonad.Cofree (Cofree (..))
import "base" Data.Bitraversable (Bitraversable (..))
import "base" Data.Functor.Compose (Compose (..))
import Data.Apart (Apart (..))
import Data.Apart.Shape (Shape (..))
import Data.Apart.Transformations (Scattered (..))
import Data.Apart.Structures.Stack (Stack)
type Account = Int
type Tokens = Int
data Connection
data Table
data Transaction = Transaction
{ from :: Account, amount :: Tokens, to :: Account }
type Block = Stack Transaction
type Blockchain = Scattered Stack Block (Connection, Table)
genesis :: Block
genesis = Transaction 0 1000 1 :< Nothing
block :: Block
block = Transaction 1 50 4 :< Nothing
mainchain :: Blockchain
mainchain = Apart $ block :< Converted (undefined, undefined)
verify :: Stack Transaction -> Blockchain -> Compose IO Maybe Block
verify txs chain = undefined