Giter Site home page Giter Site logo

omefire / ghcvm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from typelead/eta

0.0 1.0 0.0 4.23 MB

A Haskell to JVM compiler that supports GHC Haskell.

License: BSD 3-Clause "New" or "Revised" License

Haskell 51.18% Shell 0.07% Logos 8.97% C++ 0.03% C 0.01% Java 39.75%

ghcvm's Introduction

GHCVM - A JVM backend for GHC

Join the chat at https://gitter.im/rahulmutt/ghcvm

This project aims to compile Haskell to the JVM, with the primary goal of seamless compatibility with GHC 7.10.3's Haskell.

Building

Stack is used to build the code generator and the Shake builder for the RTS. The RTS build is setup so that it allows for C preprocessor directives inside of Java code.

To build everything, simply run the ./build.sh script.

$ ./build.sh

Running

Simple Program

The equivalent of the program below

map :: (a -> b) -> [a] -> [b]
map f (x:xs) = f x : map f xs
map f [] = []

caf :: [Int]
caf = map (\x -> x + 1) [1..1000]

sum :: [Int] -> Int
sum (x:xs) = x + sum xs
sum _ = 0

main :: IO ()
main = do
  print $ sum caf
  return ()

has been successfully hand-compiled to work with the GHCVM RTS. The command

$ ./run.sh

is used to run this program.

GHCVM Compiler

The ghcvm executable does nothing more than generate a stub .class file for now. Once the code generator is ready, it will do something more exciting.

$ stack exec -- ghcvm --make Main.hs

All the options that are supported by GHC are currently allowed. The options will be filtered in the future.

Design Documents

Goals

We aim to meet the following goals:

  • Easy interop with Java libraries
  • High performance lazy functional language implementation
  • Seamless integration with Java IDEs
    • IntelliJ
    • Eclipse
    • Android Studio
  • Optimize for specific JVM implementations
    • HotSpot VM
    • Dalvik VM (for Android compatibility, a lightweight runtime)
  • Support hot code reloading
  • Re-use GHC's infrastructure
    • Keep a several-month lag with respect to ghc's release cycle
    • CLI should match that of ghc's

Progress

Completed Items

  • A majority of the single- and multi-threaded RTS and primops have been implemented.
  • A sample hand-compiled program is ready. See sample/mapandsum.

Pending Items

  1. Work on the code generator.
  2. Port the base library.

Contributing

As you can see, this project is a large undertaking. If you would love to run your Haskell programs on the JVM and accelerate this project, join us on Gitter and we'll let you know how you can help out.

License

GHCVM is available under the BSD 3-Clause License, see LICENSE for more information.

Gratitude

We would like to specifically thank the following groups/people:

Thank you guys!

ghcvm's People

Contributors

rahulmutt avatar excaliburzero avatar gitter-badger avatar

Watchers

Omar Mefire avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.