[clean-list] Passing an environment around

=?iso-8859-1?Q?Jos=E9_Romildo_Malaquias?= romildo@urano.iceb.ufop.br
Wed, 18 Oct 2000 15:58:07 -0200


On Wed, Oct 18, 2000 at 10:47:44AM -0700, Shiv wrote:
> 
> Why not define +,-, etc. in the usual overloaded way as Exp Exp ->
> Exp, and define a separate function simplify :: Exp Env -> Exp to
> handle all the Env stuff?

Do you mean simply define the overloaded operators to construct
an expression without attempting simplifying it, like

  (+) x y = App Sum [x,y]

and then have a general simplify function?

  simplify :: Exp Env -> Exp
  simplify x env = ...

The algorithms for simplifying an expression is not a
simple one. There are many things to consider in its implementation.
By the way, the hole of the library is to implement it.
For sure it has to be broken in smaller pieces. That ones
also will have to broken yet smaller piecies (divide to
conquer). So at the end there will be several auxiliary
functions to simplify. Each one will need the environment,
directly, or indirectly to pass to other functions. Now
take one of this smaller functions. In its body we want
to construct a (maybe parcial) result. This result will
be obtained using the operations with expressions, mainly
the basic ones (addition, subtraction, multiplication, ...).
What do I get? Having to pass expressions arguments and the
environment in those function calls we are come back to
the initial problem of an awkward notation for algebraic
expressions, far from the Mahtematical notation. Note that
in the process of simplification we do not want to use
overloaded operators, as they now just construct expressions,
without trying to transform them.

Hope that clarifies the point.

Regards,

Romildo
-- 
Prof. José Romildo Malaquias <romildo@iceb.ufop.br>
Departamento de Computação
Universidade Federal de Ouro Preto
Brasil