{"id":16306935,"url":"https://github.com/nponeccop/hnc","last_synced_at":"2025-03-16T14:30:35.351Z","repository":{"id":66652645,"uuid":"2534352","full_name":"nponeccop/HNC","owner":"nponeccop","description":"HN Compiler","archived":false,"fork":false,"pushed_at":"2019-03-10T03:01:01.000Z","size":1765,"stargazers_count":62,"open_issues_count":48,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-02-27T09:50:40.835Z","etag":null,"topics":["compiler","haskell","optimization","purescript","rust"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nponeccop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.LESSER","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2011-10-07T18:27:55.000Z","updated_at":"2023-01-21T22:43:00.000Z","dependencies_parsed_at":"2023-03-05T17:30:16.124Z","dependency_job_id":null,"html_url":"https://github.com/nponeccop/HNC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nponeccop%2FHNC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nponeccop%2FHNC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nponeccop%2FHNC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nponeccop%2FHNC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nponeccop","download_url":"https://codeload.github.com/nponeccop/HNC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818171,"owners_count":20352629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","haskell","optimization","purescript","rust"],"created_at":"2024-10-10T21:11:59.778Z","updated_at":"2025-03-16T14:30:34.626Z","avatar_url":"https://github.com/nponeccop.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quick Start\n\n[![Build Status](https://secure.travis-ci.org/nponeccop/HNC.png?branch=master)](http://travis-ci.org/nponeccop/HNC)\n[![Stories in Ready](https://badge.waffle.io/nponeccop/HNC.png?label=ready\u0026title=Ready)](https://waffle.io/nponeccop/HNC)\n\n## Compilation\n\nHNC is buildable by both `cabal sandbox` and `stack`, on Windows, Linux and MacOS, in 64 or 32 bits.\n\n### Stack\n\n```\nstack update\nstack setup\nstack install\n$(stack path --local-bin)/spl-hnc -O hn_tests/euler6.hn\n```\n\n### Cabal sandbox\n\n```\ncabal update\ncabal sandbox init\ncabal install\n.cabal-sandbox/bin/spl-hnc -O hn_tests/euler6.hn\n```\n\n## Arch Linux\n\nOn Arch you can shorten build time by using prebuilt libraries\nfrom [ArchHaskell](https://wiki.archlinux.org/index.php/ArchHaskell) project. \n\nAdd 2 ArchHaskell binary repositories (`haskell-core` and `haskell-web`) to `pacman.conf`. Install\nthe following prebuilt packages from there to avoid building them. GHC comes\nas a dependency.\n\n```\nsudo pacman -S cabal-install haskell-{adjunctions,haskell-src-exts,hunit,logict,parsec,quickcheck,safe}\n```\n\nProceed to the general compilation steps for Cabal sandbox described above\n\n## Advanced use\n\n- run tests (`spl-test-hunit-exe` is the primary suite)\n- read wiki\n- talk to me at https://gitter.im/nponeccop/HNC\n- run our main test suite (`dist/build/spl-test-hunit-exe/spl-test-hunit-exe`)\n- run `hnc` with either `-O` or `--dump-opt` option to see our first attempts at optimization\n- follow instructions below to feed generated `.cpp` files to a C++ compiler \n  and linker either directly or by using our extension to Boost.Build.\n\nYou'll need MSVC/GCC, Boost and Boost.Build.\n\n# Under the hood\n\nHNC is an open-source cross-platform compiler based on modern technologies: Glasgow Haskell Platform, \nUUAGC attribute grammar preprocessor, Parsec parsing library, HOOPL graph optimization library, unification-fd structural unification library. The codebase is tiny: less than 4 KLOC, in the spirit of VPRI Ometa.\n\n## State of affairs\n\nMany HN programs can already be compiled into an ugly functional subset of C++ and \nthen into executables and run (see `hn_tests` folder for `.hn` sources and `.cpp` targets). \nA UDP echo server and a few Project Euler problems are the only useful programs so far, \nbut mostly because we are too lazy to write more examples.\n\n## What is done\n\n- Parser\n- Type inference using UUAG, including injection of explicit template parameters when C++ doesn't infer them\n- Identifier- and scope-preserving translation from AST into graph IR and back using HOOPL dominator analysis\n- An optimizer of the IR using HOOPL (almost; only inlining and dead code elimination)\n- Compiler of closures into C++ functors using UUAG (almost)\n- C++ pretty printer (almost)\n- A Boost.Build plugin to integrate .hn files into C++ projects\n\n## Advances as of Mar 8 2017\n\n- Split Parser and Unifier into separate self-contained components\n- Joined efforts with https://groupoid.space and https://github.com/ptol/oczor projects\n- Working on extracting other components to make HNC a sort of toy compiler construction framework\n- Working on loop generation\n\n## Advances as of Jul 21 2015\n\n- Fixed almost all optimizer bugs\n\n## What is not done\n\n- Proper error reporting\n- Assignments\n- The instantiator of polymorphic code into monomorphic is not implemented\n- Module system, namespace support, HNI implementation and C++ integration in general are rudimentary or missing\n- Priorities of C++ infix operators are broken\n- RAII should be used with care\n- SPL support is almost missing\n- Polymorphic constants like “empty list” are not supported\n\n# Setting up MSVC and Boost\n\n- Install free Visual C++ Express or non-free Visual Studio\n- Download Boost library from boost.org. \n- Extract `boost` subfolder from the distribution. It's the folder containing header files for all libraries.\n\nCreate `config.cmd` one level above HNC folder, so it's not under source control:\n\n```cmd\n@set INCLUDE=folder-containing-boost-subfolder\n@call \"%VS100COMNTOOLS%..\\..\\VC\\vcvarsall.bat\"\n```\n\n`VS100COMNTOOLS` is environment variable name set by VC 10.0 installer. Use `set | findstr COMN` to find \nout which version(s) of Visual C you have installed and change the `.cmd` file accordingly.\n\nrun `testAll.cmd` from `hn_tests` folder. You should see `tmp-*.cpp` files being generated \nfrom `.hn` sources and compiled into `.obj` files.\n\n# Setting up GCC\n\nThe generated code is not specific to MSVC or Windows, so any other Boost-compatible C++ compiler \nand platform should work too. However, the scripts to run test suite are not there yet. \n\nTo run `deref1.cpp` test manually with GCC, run\n\n```\ngcc -I../cpplib/include test.cpp ../cpplib/lib.cpp -lstdc++ --std=c++0x\n```\n\nfrom `hn_tests` folder if Boost headers are installed globally to `/usr/include`, or\n\n```\ngcc -I../cpplib/include -Ifolder-containing-boost-subfolder test.cpp  ../cpplib/lib.cpp -lstdc++ --std=c++0x\n```\n\nif Boost headers are manually unpacked locally.\n\n## License\n\nDistributed under GNU Lesser General Public Licence Version 3.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnponeccop%2Fhnc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnponeccop%2Fhnc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnponeccop%2Fhnc/lists"}