{"id":22410569,"url":"https://github.com/jiriklepl/masters-thesis-code","last_synced_at":"2026-02-04T10:18:38.175Z","repository":{"id":39339749,"uuid":"347817233","full_name":"jiriklepl/masters-thesis-code","owner":"jiriklepl","description":"This is a supplementary repository for my master's thesis","archived":false,"fork":false,"pushed_at":"2022-07-21T14:32:50.000Z","size":1286,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-03T14:47:52.282Z","etag":null,"topics":["cabal","cmm","compiler","haskell","language","llvm","master-thesis","masters-thesis","mff-uk"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiriklepl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-15T02:52:48.000Z","updated_at":"2023-01-29T04:49:13.000Z","dependencies_parsed_at":"2022-09-05T04:20:50.572Z","dependency_job_id":null,"html_url":"https://github.com/jiriklepl/masters-thesis-code","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiriklepl%2Fmasters-thesis-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiriklepl%2Fmasters-thesis-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiriklepl%2Fmasters-thesis-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiriklepl%2Fmasters-thesis-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiriklepl","download_url":"https://codeload.github.com/jiriklepl/masters-thesis-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228304107,"owners_count":17898920,"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":["cabal","cmm","compiler","haskell","language","llvm","master-thesis","masters-thesis","mff-uk"],"created_at":"2024-12-05T13:09:43.518Z","updated_at":"2026-02-04T10:18:38.132Z","avatar_url":"https://github.com/jiriklepl.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CHMMM\n\nThis repository contains the prototype compiler for my master's thesis.\n\nIt is a proof-of-concept implementation for a modified version of the C-- language showcasing type inference in the context of systems programming and inference-guided automatic resource management.\n\n## Dependencies\n\n- cabal (version 3.2+; preferably version 3.6.2 acquired through ghcup)\n- ghc (version 8.8.4 - 9.0.2; preferably version 8.10.7 acquired through ghcup)\n- llc (version 12+; preferably version 12)\n\nTwo modified cabal packages included as git submodules in the `vendor` directory:\n\n- llvm-hs-pure from [https://github.com/jiriklepl/llvm-hs](https://github.com/jiriklepl/llvm-hs), modified version of [https://github.com/llvm-hs/llvm-hs](https://github.com/llvm-hs/llvm-hs)\n- llvm-hs-pretty from [https://github.com/jiriklepl/llvm-hs-pretty](https://github.com/jiriklepl/llvm-hs-pretty), modified version of [https://github.com/llvm-hs/llvm-hs-pretty](https://github.com/llvm-hs/llvm-hs-pretty)\n\n## Building\n\nTo get the repository:\n\n```sh\ngit clone https://github.com/jiriklepl/masters-thesis-code.git\ncd masters-thesis-code\n```\n\nTo build the project:\n\n```sh\ngit submodule init\ngit submodule update\ncabal build --only-dependencies Compiler\ncabal build Compiler\n\n# development documentation:\ncabal haddock Compiler\n```\n\n## Running\n\nFor general use:\n\n```sh\ncabal run Compiler -- [options...] input_file\n```\n\nFor `/dev/stdout` output, use:\n\n```sh\ncabal run Compiler -- -o - input_file\n```\n\n### User documentation\n\nThe usage of the compiler is explained by the standardized `--help`:\n\n```sh\ncabal run Compiler -- -h\n```\n\n### Testing examples\n\nFor running the testing examples in the folder `examples/`:\n\n```sh\n./run_examples.sh\n```\n\nSome of the examples test the compiler for invalid input, which will cause several error messages to be printed out during the process.\n\n## Development documentation\n\nThe source code is documented with Haddock. You can build the HTML documentation by running:\n\n```sh\ncabal haddock Compiler\n```\n\nThis command is quite verbose but its output ends with the location of the index file of the generated documentation (it should be somewhere in the `dist-newstyle` folder, most likely in `dist-newstyle/build/\u003carch\u003e/\u003cghc-version\u003e/Compiler-0.1.0.0/x/Compiler/doc/html/Compiler/Compiler/index.html`).\n\nWhen reading the source files of the program, we suggest using Haskell Language Server (HLS), which parses the documentation comments and makes the documentation more easily accessible.\n\n### Project outline\n\nThe project contains many modules of varying significance documented with Haddock, here we list the main ones:\n\n- `CMM.Pipeline`: contains the high-level logic of the compiler and wrappers for the main phases of the compiler pipeline\n- `CMM.Lexer`: contains the definition of the tokenization phase\n- `CMM.Parser`: contains the definition of the parsing phase\n- `CMM.AST`: contains the definitions of various abstract syntactic tree (AST) nodes used as an representation of the program\n- `CMM.AST.Flattener`: defines the function `flatten`, which flattens the given AST\n- `CMM.AST.Blockifier`: defines the function `blockify`, which blockifies the procedures in the given AST, annotating each statement with a block annotation (that assigns the given statement to a corresponding basic block). It also produces the `BlockifierState`, which is refined by `CMM.FlowAnalysis`\n- `CMM.FlowAnalysis`: defines the flow analysis for a given procedure. It is issued by `CMM.Blockifier` and refines its `BlockifierState`\n- `CMM.Inference.Preprocess`: contains the definition of the function `preprocess`, which performs the inference preprocessing phase: elaborates the AST and generates the constraints that represent the type semantics of the program\n- `CMM.Inference`: defines the function `reduce`, which performs the inference pipeline on the given set of constraints (facts), producing an `InferencerState` that can interpret types of the elaborated AST\n    - The various data are defined in: `CMM.Inference.Type`, `CMM.Inference.TypeCompl`, `CMM.Inference.TypeKind`, `CMM.Inference.Properties`, `CMM.Inference.Fact`, `CMM.Inference.DataKind` , `CMM.Inference.Constness`\n- `CMM.Monomorphize`: contains the definition of the function `monomorphize`, which monomorphizes the given program represented by elaborated AST. It uses the `InferencerState` to interpret each type\n- `CMM.FillElabs`, `CMM.Mangle`: these two modules define the postprocessing of monomorphized code - filling-in concrete types in place of type variables according and name-mangling of monomorphic copies of polymorphic top-level definitions\n- `CMM.Translator`: contains the definition of the function `translate`, which performs the translation phase on an elaborated and blockified AST - emission of the LLVM assembly. It uses `BlockifierState` and `InferencerState` to interpret the control flow and types, respectively\n\nModules `LLVM.*` in directory `vendor/*` are from modified versions of packages llvm-hs-pure and llvm-hs-pretty\n\n## Code style and testing\n\nThe source files are formatted by `hindent` and checked by `hlint` (should not produce any hints). The source should compile without warnings (tested with ghc-8.10.7). The script `.\\run_examples.sh` should compile all example files and successfully interpret them by `llc`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiriklepl%2Fmasters-thesis-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiriklepl%2Fmasters-thesis-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiriklepl%2Fmasters-thesis-code/lists"}