Home

Awesome

<!--madoko Title : Libhandler Author : Daan Leijen Logo : True code { background-color: #EEE; } [TITLE] -->

Overview

Warning: this library is still under active development and the API may change.

libhandler implements algebraic effect handlers in C. It works by capturing stacks in safe and portable manner. Algebraic effects handlers can for example be used to program asynchronous code in straightline manner and we hope to use it to make programming with libuv more convenient.

This library is described in detail in the accompanying technical report. For a primer on algebraic effects, see the relevant section in the koka book.

Enjoy!
-- Daan.

Building

Building libhandler consists of generating a static C library that can be linked in your own projects. libhandler is written to be as portable as possible but it depends on some platform specific assumptions regarding stacks and setjmp implementations. On new platforms please test carefully. Currently tested platforms include:

C++ support is working but still under development.

There is an initial test code for integrating with libuv in the test/libuv directory (in the dev branch). The Microsoft IDE solution contains a project for building with libuv.

Unix/MacOSX

Build using regular configure and make:

  $ ./configure
  $ make depend
  $ make

Use VARIANT=release to build a release version, and tests as a target to run tests. For example:

  $ make tests VARIANT=release

Configuration options:

Make parameters:

Make targets:

Windows

There are three ways to build on Windows:

  1. Use the Microsoft Visual C++ IDE. The 2015 Community edition is available for free for non-commercial use. The solution can be found at:

    ide/msvc/libhandler.sln
    
  2. Enable the "Linux subsystem" on Windows 10. See MSDN for installation instructions. Once enabled, you can simply run bash on the command prompt to enter Ubuntu Linux from Windows. Use apt to install the development tools:

    • sudo apt-get update
    • sudo apt install build-essential
    • sudo apt install clang

    After this you can run configure and make as described above.

  3. On older Windows versions, you can use msys2, available at http://msys2.github.io. Please follow the installation instruction carefully. After install, you can install further tools using the msys2 package manager:

    • pacman -S mingw-w64-x86_64-gcc (c compiler)
    • pacman -S mingw-w64-x86_64-gdb (debugger)
    • pacman -S make (make)

    After this you can run configure and make as described above.

Successful configurations bash on Windows have been:

Successful configurations on Windows using msys2 have been:

Using the Visual Studio IDE:

LibUV on Windows

Enabled in Visual Studio for x64 builds. You need to put the libuv headers and binaries in a libuv folder under the main libhandler folder. Binaries for Windows can be found on libuv.org.