Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] Announce: Bindlib 3.0

1 view
Skip to first unread message

Christophe Raffalli

unread,
Oct 3, 2006, 8:57:47 AM10/3/06
to caml-list

I am pleased to announce the 3.0 version of Bindlib:
http://www.lama.univ-savoie.fr/~raffalli/bindlib.html

bindlib is a library and a camlp4 syntax extension for the
OCaml language. It proposes a set of tools to manage data structures
with bound and free variables. It includes fast substitution and management
of variables names including renaming.

As an exemple here is a piece of code to print and normalize (efficiently) lambda-terms:

Warning: it does not work with ocaml 3.10(cvs) due to the camlp4 revision. A new version is planned
when 3.10 is officially out.

----------------8<-----------------------
type term =
App of term * term
| Abs of (term,term) binder
| FVar of term variable

let fVar (x:term variable) = FVar(x)

(* simple printing of term *)

let rec print_term = function
App(t1,t2) ->
print_string "(";
print_term t1;
print_string " ";
print_term t2;
print_string ")"
| Abs f ->
match f with bind fVar x in t ->
print_string "fun ";
print_string (name_of x);
print_string " ";
print_term t
| FVar(v) ->
print_string (name_of v)

(* weak head normal form *)

let rec whnf = function
App(t1,t2) as t0 -> (
match (whnf t1) with
Abs f -> whnf (subst f t2)
| t1' -> if t1' != t1 then App(t1', t2) else t0)
| t -> t

(* call by name normalisation *)
let norm t = let rec fn t =
match whnf t with
Abs f ->
match f with bind fVar x in u ->
Abs(^ bindvar x in fn u ^)
| t ->
let rec unwind = function
FVar(x) -> bindbox_of x
| App(t1,t2) -> App(^unwind t1,fn t2^)
| t -> assert false
in unwind t
in unbox (fn t)
----------------8<-----------------------

--
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christoph...@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

0 new messages