Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tcr/corollary
Cross-compiler from Haskell to Rust, plus parser-haskell.
https://github.com/tcr/corollary
corollary cross-compiler haskell parsing-library rust
Last synced: about 2 months ago
JSON representation
Cross-compiler from Haskell to Rust, plus parser-haskell.
- Host: GitHub
- URL: https://github.com/tcr/corollary
- Owner: tcr
- Created: 2017-05-04T05:29:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-22T19:12:48.000Z (over 7 years ago)
- Last Synced: 2024-10-30T00:35:20.783Z (about 2 months ago)
- Topics: corollary, cross-compiler, haskell, parsing-library, rust
- Language: Rust
- Homepage:
- Size: 4 MB
- Stars: 74
- Watchers: 9
- Forks: 6
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Corollary: Haskell to Rust conversion
[![https://img.shields.io/crates/v/corollary.svg](https://img.shields.io/crates/v/corollary.svg)](http://crates.io/crates/corollary)
Corollary is a very experimental Haskell to Rust compiler. The goal is to automate the syntatic conversion of Haskell into Rust, letting users manually finish the conversion into idiomatic Rust code. Along with an (extremely loose) adaptation of Haskell methods in `corollary-support`, this can expediate the process of completing a full port.
**Current status: Looking for maintainers.** Corollary can parse and translate entire files, with varying results. Source code specific hacks, along with manual translation, were used for the [language-c](http://github.com/tcr/parser-c) port of Haskell's C parsing library.
Given this project was purpose-built for porting a single library, you'll find source-specific hacks throughout the codebase, though they should ultimately be removed. There are no solutions yet for the following problems:
* Haskell's module and import system
* Haskell's garbage collection (instead, given Haskell values are immutable, we liberally .clone() most values when passed around instead)
* Top-level functions without explicit type declarations
* Monads and HKT
* Tail recursion
* True laziness
* Or currying (lacking a better way to involve Haskell's type analysis).## Usage
Corollary can be used as a binary:
```
cargo install corollary
corollary input/file/path.hs -o target/output.rs
```Thsi converts a single source file from Haskell into Rust. You can omit the `-o` parameter to write the file to stdout. Additionally, you can run a file using the `--run` parameter.
Corollary will strip any code in a `{-HASKELL-} ... {-/HASKELL-}` block and include any code in a `{-RUST ... /RUST-}` block embedded in a file. (See `corollary/test` for examples.) This allows you to `--run` a Haskell file directly, given it is self-contained (does not rely on Haskell's module system).
## Development
Clone this repository including its test dependencies:
```
git clone http://github.com/tcr/corollary --recursive
```These are the crates contained in this repo:
* **`parser-haskell/`**, an original Haskell Parser written in LALRPOP.
* **`corollary/`**, an experimental Haskell to Rust compiler.
* **`corollary-support/`**, a support crate for converted Haskell code to use.In addition, libraries to test Corollary against exist in the `deps/` directory.
## References
* [Ten Things You Should Know About Haskell Syntax](https://www.fpcomplete.com/blog/2012/09/ten-things-you-should-know-about-haskell-syntax)
* [Haskell: The Confusing Parts](http://echo.rsmw.net/n00bfaq.html)## License
Corollary and `parser-haskell` are licensed as MIT or Apache-2, at your option.