Seeded root leaf prep for wire
This commit is contained in:
@@ -84,13 +84,9 @@ nix flake check # or: nix build .#test
|
|||||||
| `elimLambdaSingle` | Lambda elimination: eta reduction, SDef binding, semantics preservation |
|
| `elimLambdaSingle` | Lambda elimination: eta reduction, SDef binding, semantics preservation |
|
||||||
| `stressElimLambda` | Lambda elimination stress test: 200 vars, 800-body curried lambda |
|
| `stressElimLambda` | Lambda elimination stress test: 200 vars, 800-body curried lambda |
|
||||||
|
|
||||||
### Adding tests
|
### Suggesting tests
|
||||||
|
|
||||||
1. Append a `testCase "Description" $ do ...` block to the appropriate test group in `test/Spec.hs`.
|
You do not write or modify tests. The user writes tests to constrain your outputs. You must adhere your code to tests or suggest modifications to tests.
|
||||||
2. Import any modules you need (lexer/parser are available via `runParser` from `Text.Megapparsec`; evaluation via `evalTricu`, `parseTricu`, `result`).
|
|
||||||
3. Run `nix flake check` to verify.
|
|
||||||
|
|
||||||
> The test-suite in `tricu.cabal` pulls in `src/` as `hs-source-dirs`, so tests import modules directly (e.g., `import Eval`, `import Lexer`). This is intentional — tests exercise the full pipeline end-to-end.
|
|
||||||
|
|
||||||
## 4. tricu Language Quick Reference
|
## 4. tricu Language Quick Reference
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ initContentStore = do
|
|||||||
execute_ conn "CREATE TABLE IF NOT EXISTS merkle_nodes (\
|
execute_ conn "CREATE TABLE IF NOT EXISTS merkle_nodes (\
|
||||||
\hash TEXT PRIMARY KEY, \
|
\hash TEXT PRIMARY KEY, \
|
||||||
\node_data BLOB NOT NULL)"
|
\node_data BLOB NOT NULL)"
|
||||||
|
-- Seed canonical Leaf node payload (0x00)
|
||||||
|
putMerkleNode conn NLeaf
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
getContentStorePath :: IO FilePath
|
getContentStorePath :: IO FilePath
|
||||||
@@ -95,13 +97,11 @@ storeTerm conn newNamesStrList term = do
|
|||||||
-- | Reconstruct a Tree Calculus term from its Merkle root hash.
|
-- | Reconstruct a Tree Calculus term from its Merkle root hash.
|
||||||
-- Recursively loads nodes and rebuilds the T structure.
|
-- Recursively loads nodes and rebuilds the T structure.
|
||||||
loadTree :: Connection -> MerkleHash -> IO (Maybe T)
|
loadTree :: Connection -> MerkleHash -> IO (Maybe T)
|
||||||
loadTree conn h
|
loadTree conn h = do
|
||||||
| h == nodeHash NLeaf = return (Just Leaf) -- NLeaf is implicit, not stored
|
maybeNode <- getNodeMerkle conn h
|
||||||
| otherwise = do
|
case maybeNode of
|
||||||
maybeNode <- getNodeMerkle conn h
|
Nothing -> return Nothing
|
||||||
case maybeNode of
|
Just node -> Just <$> buildTree node
|
||||||
Nothing -> return Nothing
|
|
||||||
Just node -> Just <$> buildTree node
|
|
||||||
where
|
where
|
||||||
buildTree :: Node -> IO T
|
buildTree :: Node -> IO T
|
||||||
buildTree NLeaf = return Leaf
|
buildTree NLeaf = return Leaf
|
||||||
@@ -116,7 +116,9 @@ loadTree conn h
|
|||||||
-- | Store all nodes of a Merkle DAG by traversing the Term and building/storing nodes.
|
-- | Store all nodes of a Merkle DAG by traversing the Term and building/storing nodes.
|
||||||
-- Returns the hash of the root node.
|
-- Returns the hash of the root node.
|
||||||
storeMerkleNodes :: Connection -> T -> IO MerkleHash
|
storeMerkleNodes :: Connection -> T -> IO MerkleHash
|
||||||
storeMerkleNodes _ Leaf = return $ nodeHash NLeaf
|
storeMerkleNodes conn Leaf = do
|
||||||
|
putMerkleNode conn NLeaf
|
||||||
|
return $ nodeHash NLeaf
|
||||||
storeMerkleNodes conn (Stem t) = do
|
storeMerkleNodes conn (Stem t) = do
|
||||||
childHash <- storeMerkleNodes conn t
|
childHash <- storeMerkleNodes conn t
|
||||||
let thisNode = NStem childHash
|
let thisNode = NStem childHash
|
||||||
|
|||||||
Reference in New Issue
Block a user