Skip to content
/ kla Public
forked from billosys/kla

An LFE Wrapper Library used to Dress Up Erlang Libraries in a Lispy Costume

License

Notifications You must be signed in to change notification settings

lfex/kla

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

klä

Build Status LFE Versions Erlang Versions Tags

An LFE Wrapper Library used to Dress Up Erlang Libraries in a Lispy Costume

Project logo

Table of Contents

Introduction

This is a utility library created and used simply for aesthetics.

Dependencies

As of version 0.5.0, this project assumes that you have rebar3 installed somwhere in your $PATH. It no longer uses the old version of rebar. If you do not wish to use rebar3, you may use the most recent rebar2-compatible release of kla: 0.4.2.

Installation

Just add it to your rebar.config deps:

{deps, [
    ...
    {kla, "0.9.1"}
]}.

And then do the usual:

    $ rebar compile

Usage

To use this library, one does the following (usually in an include file):

  1. Create a function that returns a list of function names as they would be called in an LFE application.
  2. Create a generator function that will convert these to Erlang names and then look them up in the specified Erlang module.
  3. Call the generate function in the include.
  4. Use the include in your application.

The moneta project makes heavy use of kla; here's an excerpt of the "query" include file:

(eval-when-compile
  (defun get-api-funcs ()
    '((append 1) (append 2)
      (cursor 1) (cursor 2)
      (delete-cursor 1)
      (eval 1) (eval 2)
      (e 1) (e 2)
      (fold 3) (fold 4)
      (format-error 1)
      (info 1) (info 2)
      (keysort 2) (keysort 3)
      (next-answers 1) (next-answers 2)
      (q 1) (q 2)
      (sort 1) (sort 2)
      (string-to-handle 1) (string-to-handle 2) (string-to-handle 3)
      (table 2))))

(defmacro generate-api ()
  `(progn ,@(kla:make-funcs (get-api-funcs) 'qlc)))

(generate-api)

Then, in the library source file mnt-qry:

(defmodule mnt-qry
  (export all))

(include-lib "moneta/include/mnt-qry.lfe")

at which point all the functions listed in get-api-funcs are now available for use in mnt-qry. Calling the Lisp-style functions in mnt-qry will result in calls to the under-score functions in the Erlang qlc library.

About

An LFE Wrapper Library used to Dress Up Erlang Libraries in a Lispy Costume

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • LFE 47.8%
  • Makefile 26.4%
  • Erlang 21.9%
  • Shell 3.9%