alms: a practical affine language

[ bsd3, compilers-interpreters, program ] [ Propose Tags ]

Alms is an experimental, general-purpose programming language that supports practical affine types. To offer the expressiveness of Girard’s linear logic while keeping the type system light and convenient, Alms uses expressive kinds that minimize notation while maximizing polymorphism between affine and unlimited types. A key feature of Alms is the ability to introduce abstract affine types via ML-style signature ascription. In Alms, an interface can impose stiffer resource usage restrictions than the principal usage restrictions of its implementation. This form of sealing allows the type system to naturally and directly express a variety of resource management protocols from special-purpose type systems.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
editline

Enable line editing using the editline package

Enabled
parsec3

Use version 3 of the parsec package

Enabled
readline

Enable line editing using the readline package

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.4.9, 0.4.9.1, 0.4.10, 0.4.11, 0.4.12, 0.5.0, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9
Dependencies array (>=0.3), base (>=4 && <5), containers (>=0.1), directory (>=1.0), editline (>=0.2.1), filepath (>=1.1), haskell98, HUnit (>=1.2), mtl (>=1.1), network (>=2.2), parsec (>=2 && <4), pretty (>=1), QuickCheck (>=2), random (>=1), readline (>=1.0), syb (>=0.1), template-haskell (>=2.0) [details]
License BSD-3-Clause
Copyright 2010, Jesse A. Tov
Author Jesse A. Tov <tov@ccs.neu.edu>
Maintainer tov@ccs.neu.edu
Category Compilers/Interpreters
Home page http://www.ccs.neu.edu/~tov/pubs/alms
Uploaded by JesseTov at 2011-03-12T21:40:39Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables alms
Downloads 12287 total (36 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-28 [all 8 reports]

Readme for alms-0.5.0

[back to package description]
This is a prototype implementation of Alms, an affine language with
modules and subtyping.

Please see http://www.ccs.neu.edu/home/tov/pubs/alms/ for more
information.

CONTENTS

 * GETTING STARTED
 * WHAT TO TRY
 * PAPER SYNTAX VERSUS ASCII SYNTAX
 * EDITLINE TROUBLE


GETTING STARTED

  Alms requires GHC to build.  It is known to work with GHC 6.12.1 and
  6.10.4, and likely no longer works with GHC 6.8.

  Provided that a recent ghc is in your path, to build on UNIX it ought
  to be be sufficient to type:

    % make

  This should produce an executable "alms" in the current directory,

  If this fails, it may also be necessary to either install the editline
  package first or disable line editing (Please see EDITLINE TROUBLE).

  On Windows, build with Cabal:

    > runghc Setup.hs configure
    > runghc Setup.hs build

  This produces an executable in "dist\build\alms\alms".

  Cabal should work on UNIX as well, but mixing Cabal and make leads to
  linker errors, so it's probably best to stick with one or the other.


WHAT TO TRY

  Examples from the paper and several more are in the examples/
  directory.  The examples from section 2 of the POPL submission are in:

    examples/ex60-popl-deposit.alms
    examples/ex61-popl-AfArray.alms
    examples/ex62-popl-AfArray-type-error.alms
    examples/ex63-popl-CapArray.alms
    examples/ex64-popl-CapLockArray.alms
    examples/ex65-popl-Fractional.alms
    examples/ex66-popl-RWLock.alms

  Other notable examples include two implementations of session types,
  an implementation of Sutherland-Hodgman re-entrant polygon clipping
  (1974) using session types, and the tracked Berkeley Sockets API from
  our ESOP 2010 paper:

    lib/libsessiontype.alms
    lib/libsessiontype2.alms
    examples/session-types-polygons.alms
    lib/libsocketcap.alms

  The echo server from the ESOP paper, which uses libsocketcap, is in
  examples/echoServer.alms.  To try it, listening on port 10000, run:

    % ./alms examples/echoServer.alms 10000

  To connect to the echo server, you can run

    % ./alms examples/netcat.alms localhost 10000

  from another terminal.

  The examples directory contains many more examples, many of which are
  small, but demonstrate type or contract errors -- the comment at the
  top of each example says what to expect.  Run many of the examples
  with:

    % make examples

  Or run the examples as regression tests (quietly):

    % make tests

  Of course, you can also run the interpreter in interactive mode:

    % ./alms

  You can load libraries from the command line like this:

    % ./alms -l libsocketcap

  Or from within the REPL like this:

    #- #load "libsocketcap"

  Finally, it may be helpful to know about the #i command for asking the
  REPL about identifiers:

    #- #i list Exn *
    type +`a list : a = Cons of `a * `a list | Nil
        -- built-in
    module Exn
        -- defined at "lib/libbasis.alms" (line 2, col. 3 to line 23, col. 3)
    type +`a * +`b : a \/ b   -- built-in
    val ( * ) : int -> int -> int   -- built-in


PAPER SYNTAX VERSUS ASCII SYNTAX

The language as presented in the paper is faithful to the language as
implemented, except for issues of pretty printing:

  LaTeX (what the paper says)     ASCII (what you type)
  -----------------------------------------------------
  \forall \exists \lambda         all ex fun   (binders)
  \alpha                          'a           (unlimited type variable)
  \hat\alpha                      `a           (affine type variable)
  \to^A                           -o           (affine arrow)
  \to^{\hat\alpha}                -[a]>        (arrow with qualifier)
  \sqcup \sqcap                   \/ /\        (qualifier join and meet)
  \pm \baro + -                   = * + -      (variances)


EDITLINE TROUBLE

  Line editing is enabled in the REPL by default, which depends on the
  editline Cabal package.  If make fails and says something about
  editline, then there are three options:

   - Disable line editing:

       % make clean; make FLAGS=-editline

   - Use readline instead:

       % make clean; make FLAGS=readline

   - Try to install editline or readline . . .

  Installing editline can be kind of touchy.  On my system,

    % cabal install editline

  seemed to install it, but Cabal still couldn't find it when
  building this program.  Installing editline globally made it work:

    % sudo cabal install --global editline

  (Likewise, readline didn't work until I installed it globally.)

  At this point, older versions of Cabal may give the installed library
  bad permissions, so something like this may help, depending on where
  it installs things:

    % sudo chmod -R a+rX /usr/local/lib/editline*

  If the cabal installation of the GHC package fails, it may be
  necessary first to install the C library that it depends on.  The
  source is available at http://www.thrysoee.dk/editline/.  On my Debian
  system, I was able to install it with:

    % sudo aptitude install libedit2 libedit-dev

  Note that libeditline is a *completely different* library, and
  installing that will not help.