- Map.insertWith
-- | Increments the counter
increment :: Ord a => a -> IncrementOnlyCounter a -> IncrementOnlyCounter a
increment i (IncrementOnlyCounter v) =
IncrementOnlyCounter (Map.insertWith (\a b -> a + b + 1) i 1 v)
$a function
-- returns a copy of the block with the hash set
setBlockHash :: Block -> Block
setBlockHash block = block {blockHash = calculateBlockHash block}
-- returns a copy of the block with a valid nonce and hash set
setNonceAndHash :: Block -> Block
setNonceAndHash block = setBlockHash $ block {nonce = findNonce block}
Basic Category Theory book: