caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
To: caml-list <caml-list@inria.fr>
Subject: Announce: Bindlib 3.0
Date: Tue, 03 Oct 2006 14:54:19 +0200	[thread overview]
Message-ID: <45225D7B.9010300@univ-savoie.fr> (raw)


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
---------------------------------------------


                 reply	other threads:[~2006-10-03 12:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45225D7B.9010300@univ-savoie.fr \
    --to=christophe.raffalli@univ-savoie.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).