Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
how to implement generic operators
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-10-25 (01:43)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] how to implement generic operators
On Mon, 2005-10-24 at 15:27 -0400, Jacques Carette wrote:
> skaller wrote:

> You really need your operations to be left-associative for that to make 
> sense... But in my toy interpreter for a subset of Maple (written in 
> Ocaml), I have
> type op = term -> term -> term * term
> and then in the eval() function for a term, a case
>    | Assoc ((f,init), l) -> List.fold_left f init l
> f can be created from a term by applying a term-level lambda, 

I am already doing this for types. There is also a separate
programmable term evaluator however it works only on the syntax tree
(unbound terms).

My type term calculus has lambdas and products .. but no lists.
There is no real 'term' calculus (just ad hoc reduction

Do you provide lists directly in the term calculus?
Or are they just constructed from products and sums?

It looks like I would have to

(1) provide a term calculator
(1a) extend the type calculator to support either lists
(1b) add sums and make sure recursion works

1a looks easier, clearly 1b is more general.

** the 'ad hoc' reduction rules are 'weak' things
like constant folding, plus some sophisticated
but very specialised rules for inlining and
substitution: there is no way I could really claim
this 'term calculator' I already have is a general
'calculus', in the same way that the type calculator is.

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: