/bindle

An applicative module functor implementation in CL

Primary LanguageCommon LispMIT LicenseMIT

bindle

A first-class module system for Common Lisp with module signatures and module functors.

A taste of bindle

Here’s an applicative written using bindle defmodule.

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defmodule *basic* sig
    (fun return ts)
    (fun app f-app app)
    (val map)))

(defmodule make ((mod *basic*)) *app*
  (defun return (ts)
    (mod.return ts))

  (defun app (f-app app)
    (mod.app f-app app))

  (defun derived-map (f ts)
    (app (return f) ts))

  (defun map (f xs)
    (if (eq :custom (car mod.map))
        (funcall (cadr mod.map) f xs)
        (derived-map f xs)))

  (defun mapn (f arg1 &rest args)
    (reduce (lambda (acc x) (app acc x)) args :initial-value (map f arg1))))

More

Check out the wiki for more details.

Currently Not Supported

  • Defstruct
    • You don’t get structs.
  • Accessing Inner modules from outer modules
    • This can be simulated rather easily, check out the wiki article on it here.
  • Macros
    • Due to how expanders work, macros are a bit annoying to deal with, the wiki gives a somewhat error prone implementation here.
      • This implementation adds a small overhead to a macro and only works fully on expansions which do not export anything
    • To properly include macro code into your project checkout the wiki page here (TODO: make wiki page explaining to make an expander)