{"_id":"@aryansw/heavyimp","name":"@aryansw/heavyimp","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@aryansw/heavyimp","description":"A type-checker for Heavy Imp, for CS 45600","version":"0.1.0","module":"heavyimplib.js","types":"heavyimplib.d.ts","sideEffects":false,"gitHead":"3338fff7f13eaecc23d5e6da3bad8f23d2360ad5","_id":"@aryansw/heavyimp@0.1.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-qSCSkuLeFqwoKAFa7Hx4upCdyhYPBSPDHKHj/eQVar7tqnnHShWVBlSZJcN7611G41naB9Gw4g9VN0XuIZ/vfQ==","shasum":"c915f93e0bdce0f8add2d44a76b18f2c69ba58d2","tarball":"https://registry.npmjs.org/@aryansw/heavyimp/-/heavyimp-0.1.0.tgz","fileCount":6,"unpackedSize":143516,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDaFpZeqJF81z4OIZ+ZDtCqYSPR5SLPhQKTJoF7GoOGdwIhAOpI5EaNopENIkcpN5UsdXSxa3QEp4EIdqbkLNG5q0nw"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjrSinACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqMow//TV6t+dk6xRtMFSRB3KfNDAuiMm5+7pb9mMCuXH8FMcE/nAKQ\r\nkxJqNLIBD2rxM8DtzL4qscoST2mmh5o4DQ0avr7zbtANvdsJUeJwvQLSMuWs\r\nf5CunCwRYGOR5pNg2Xk9J4Orwr1TSecayHv86F+iMlk6eEZeY+EMaEdp55+7\r\ni9Vkt52hojLVaMP6oVSYA7uHRZMv+kI4A1iuBN+k3mSDB3P+EKMwXOt3hPrj\r\n7YYoevujGyJxBsQweCJeDw/9XjiG5+MyiUFBuktsBa/elyrJj5gz/pEuRtSi\r\nDjOv6Z6IrQ0+hS2VqcTohKL/V+qGcvPDJcYdrvp/m4Vwe75JY8E25ZSovH8i\r\nkHzdFVEZvszVEWmpWZEPkugm9q493TZ+IkXgBov6Wf4FOjbVrp3YbyD8UzMc\r\nCtcfB5g8leU4r6uLvxO04rOF7SKcqmV6Q2UrRhN0ehyWVu8lWLjv1e8GS6j5\r\n7XeIlqHorS4ZGBt7HK+RzHdGo5skH2EWOJqFypZP170QySQ9PKP3rMUUT/kW\r\naU9j4oFw29kHRtgyy4+tb7zN86oaRCERCoYEwPQttcze5vCOCDaC32cIJnCt\r\nsjIuZVz3AZPQWBY9xj2r6lDuMP5fEblKiwVPUquB4u+SCKb5ipo/MuBGqfBb\r\npfQ6JJi4Yeq08l1pQJ1LyoAai8UnEfW09ug=\r\n=9MEo\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"aryansw","email":"aryan.w2203@gmail.com"},"directories":{},"maintainers":[{"name":"aryansw","email":"aryan.w2203@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/heavyimp_0.1.0_1672292519196_0.9494424389657146"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-29T05:41:59.119Z","0.1.0":"2022-12-29T05:41:59.373Z","modified":"2022-12-29T05:41:59.528Z"},"maintainers":[{"name":"aryansw","email":"aryan.w2203@gmail.com"}],"description":"A type-checker for Heavy Imp, for CS 45600","readme":"# Heapy Imp\r\n\r\nA typechecker and interpreter for Heapy Imp\r\n\r\n```lua\r\nlet x <- 0\r\nlet inc = 25\r\n\r\nwhile *x < 100 do\r\n    x <- *x + inc\r\nend\r\n```\r\n\r\n## Implemented Features\r\n- Parser\r\n    - Implemented with the help of pest, and using a lua-like syntax\r\n    - Designed such that type inference is unnecessary\r\n        - `let` always denotes a new binding\r\n        - `=` assigns to the store\r\n        - `<-` assigns to the heap\r\n        - `*` reads from the heap. No pointer arithmetic is allowed, so it must always come before an identifier.\r\n- Typechecker\r\n    - Refer to `typing_rules.pdf`\r\n- Interpreter\r\n    - Produces a map from variables to values or locations on the heap, and an array of values on the heap.\r\n    - To avoid infinite loops during quickcheck tests, the interpreter has a maximum number of iterations in a loop it can execute.\r\n- Quickcheck tests\r\n    - We have control over how many of the generated programs will be correct by first\r\n    generating correct programs and then randomly messing with them.\r\n    - Randomly generates programs, and checks that they typecheck and evaluate correctly.\r\n\r\n## Important Note About Typing Rules\r\n\r\nConditionals allow variables from either conditional branch to leak if they have the same\r\ntype in each branch. The intersection sign in T-Conditional denotes variables that have the\r\nsame type in each scope.\r\n\r\nThe behavior for this example is interesting because of this:\r\n\r\n```\r\nlet z <- 10\r\nif *z < 10 then\r\n    let x <- 5\r\n    let a = 1\r\n    let b <- 1\r\nelse\r\n    let x <- 10\r\n    let b = 1\r\n    let a <- 1\r\nfi\r\nlet y <- *x\r\n```\r\n\r\nHere, x has the same type in each branch, so the assignment on the last line succeeds. However,\r\nif we attempt to assign to either b or a we get an `UnboundVariable` error from the typechecker,\r\nsince they have different types in each branch.\r\n\r\nThe evaluator doesn't know this, so the ending scope will still contain every variable for the\r\nbranch that was actually executed.\r\n\r\n## Running and Testing\r\nYou can run programs through: `cargo run examples/<file>.imp`\r\n\r\nThere's also additional tests in the program, and in particular, there are quick-check tests to ensure the three following properties:\r\n1. Programs that type-check won't have an evaluation error\r\n2. Programs that have an evaluation error won't type-check\r\n3. \"Correct\" programs will type-check and evaluate\r\n\r\nThe best way to run these is using `cargo test --release quick_check  -- --nocapture` (the `--nocapture` is important to see the output of the tests).\r\nAdditionally, to see the output from the quickcheck library, it's necessary to set the `RUST_LOG` environment variable to \"quickcheck\".\r\n","readmeFilename":"README.md"}