Personal tools

Yhc/Erlang/Proof of concept

From HaskellWiki

Jump to: navigation, search

Contents


1 Introduction

This Wiki page describes an experiment targeting execution of Haskell programs on top of the Erlang Virtual Machine (BEAM). Haskell source code is compiled to Yhc Core with York Haskell Compiler (Yhc), then the program further discussed converts Yhc Core to Core Erlang; finally Erlang Compiler (erlc) compiles Core Erlang to the BEAM file format which can be loaded and executed by the Erlang VM.

There have been numerous discussions about Haskell (mainly GHC) runtime lacking some properties that are available in Erlang environment, as well as about possible improvements in Erlang language syntax and type system to bring some elements available in Haskell.

This experiment is an attempt to satisfy the criticists from both sides. Once it becomes possible to execute Haskell programs in Erlang environment, Haskell users get access to the robust concurrency-oriented runtime, still being able to use Haskell native syntax. Erlang users get possibility to develop some algorithms with regard to the Haskell strong type system, while still being able to code directly in Erlang, where it seems more appropriate implementation-wise.

2 Implementation details

2.1 Erlang core overview

2.2 Haskell on BEAMs ;)

2.3 Lazy computations

2.4 Haskell objects

2.4.1 Thunks

2.4.2 Data constructors

2.4.3 Special cases

2.5 Haskell calling Erlang

2.5.1 General calling convention

2.5.2 Primitive calls

2.5.3 Hardcoded BIFs

2.6 Erlang calling Haskell

2.7 Typed processes

2.7.1 Spawning processes

2.7.2 Receiving messages

2.7.3 Sending messages

3 Examples

3.1 Factorial

3.2 Merging lists

3.3 Ping-pong