• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

tcr/corollary: Cross-compiler from Haskell to Rust, plus parser-haskell.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

tcr/corollary

开源软件地址(OpenSource Url):

https://github.com/tcr/corollary

开源编程语言(OpenSource Language):

Rust 90.3%

开源软件介绍(OpenSource Introduction):

Corollary: Haskell to Rust conversion

https://img.shields.io/crates/v/corollary.svg

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 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

License

Corollary and parser-haskell are licensed as MIT or Apache-2, at your option.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
WillSewell/pusher-http-haskell: Pusher Channels Haskell HTTP Library发布时间:2022-06-18
下一篇:
Sponsor @syucream on GitHub Sponsors · GitHub发布时间:2022-06-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap