José Romildo Malaquias:

> One of the algorithms I have to implement is the
> addition of symbolic expressions. It should have
> two symbolic expressions as arguments and should
> produce a symbolic expression as the result. But
> how the result is produced is depending on series
> of flags that control how the expressions is to
> be manipulated. This set of flags should then be
> passed as a third argument to addition function.
> This is the correct way of doing it. But, being
> a Mathematics application, my system should preserve
> the tradicional Math notation (that is, infix
> operators with suitable associations defined). So
> my symbolic expression type should be an instance
> of the Num class so that the (+) operator can
> be overloaded for it. But, as the function has
> now three arguments, it cannot be a binary operator
> anymore.

... then about Monads e algumas outras coisinhas mais
ou menos bonitas.

==

I don't fully understand the issue. If it is only 
a syntactic problem, and for a given chunk, say,
a module, your set of flags is fixed, and does not change
between one expression and another, you can always define

add flagSet x y = ...-- your addition function--

and then overload

x+y = add myCurrentEnv x y

in this module. (I can't resist complaining once more about
the inadequacy of the Num class hierarchy in Haskell ...;
one will have to do the same in the Rational or Floating
instance definitions, which is clumsy).

Jerzy Karczmarczuk
Caen, France

Reply via email to