[Haskell-cafe] How to "Show" an Operation?

Ozgur Akgun ozgurakgun at gmail.com
Fri Jun 4 11:51:07 EDT 2010

One way woul be to represent them usnig a data structure. If it's only
artihmetic operations, it should be pretty easy.

data Arith = Var String
           | Plus Artih Arith
           | Mult Arith Arith
           | Pow  Arith Arith

x + y would be Plus (Var "x") (Var "y"), so on so forth..

You can even use infix constructors like :+:, :*:, :^:

On 4 June 2010 16:37, Martin Drautzburg <Martin.Drautzburg at web.de> wrote:

> Dear all,
> If I have a problem where I have to select from a set of operations, how
> would
> I print the result?
> Example: If I can chose from (x+y), (x*y), (x^2+y)...
> and I feed them all into my problem solver
> and it finds that "(x*y) is right", how can I print that string?
> --
> Martin
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100604/e7fa63d2/attachment.html

More information about the Haskell-Cafe mailing list