Version française
Home     About     Download     Resources     Contact us    
Browse thread
Announce: Bindlib 3.0
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: Announce: Bindlib 3.0

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: Christophe.Raffalli@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
---------------------------------------------