Rene de Visser <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in 
gmane.comp.lang.haskell.cafe:
> I have a somewhat complicated calculation programmed in Haskell.
> This calculation is coded without using monads.
> 
> I want to also produce a report describing the details of this calculation 
> for each particular set of inputs.
> e.g. Number of hours worked = 100. Gross pay per hour = 50. Total gross = 
> 100 * 50 = 500.
> etc.
> But about 20 times more complicated than the above.

I suggest that you consider defining an instance of Num for the type of
a "calculation result annotated with details".  A binary operator like +
can then both perform the calculation and combine the annotations.  You
probably want an additional operation (outside the Num class) that adds
a new annotation for the current intermediate result.  This way, you may
be able to reuse all or most of your calculation code for computing with
and without keeping track of the report.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
Mothers are the necessity of invention. --Bill Watterson

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to