addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

GHCJS: Bringing Haskell to the Browser

GHCJS: Bringing Haskell to the Browser
Luite Stegeman

GHCJS is a Haskell to JavaScript compiler based on GHC. Its concurrent runtime system supports lightweight threads, (asynchronous) exceptions, lazy and asynchronous IO, synchronisation primitives like MVar, and software transactional memory. A non-concurrent runtime is also available for situations where code size is of particular importance. In addition to the existing foreign function interface, GHCJS has a convenient "foreign import javascript'' calling convention, allowing users to write inline JavaScript in their Haskell program.

The compiler integrates well in the Haskell ecosystem: GHCJS implements all modern GHC extensions, including Template Haskell. Cabal supports GHCJS as a compiler flavour, and most packages on hackage can be compiled and used directly without changes. Packages with foreign dependencies can be used when a JavaScript implementation is available for the imported foreign functions.

In this talk we will see the stages and transformations in the GHCJS compilation pipeline, and discuss the design choices for translating various Haskell features to JavaScript. The second half will be more practical, with examples of interacting with (asynchronous) JavaScript code through the foreign function interface, handling browser events and doing smooth animation. If time permits, we will also briefly look at debugging the compiled code.

* * * 

Luite Stegeman has studied computer science at Utrecht University where he learned Haskell, and is the principal author of GHCJS. He currently works as a freelance programmer in the Netherlands, and is interested in combinatorics, numerical optimisation and simulation, and in bringing better tools for education and data visualisation to the web with Haskell.

Join or login to comment.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy