On 8/7/06, Ahn, Ki Yung <[EMAIL PROTECTED]> wrote:
I have posted an wiki article including one example of adding
a counter to count the number of basic operations in sorting algorithm.

http://www.haskell.org/haskellwiki/Physical_equality

This was a rather simple situation and we figured out how to
cure this by self equality check ( x==x ) forcing evaluation.

Forcing evaluation using (==) is a bit of a hack.  Luckily, we have a
better function to force evaluation: seq (which has type a -> b -> b).
"seq x y" evaluates "x" to weak head normal form before returning
"y".

Let's try another feature of Haskell to force evaluation: strict data
fields.  A ! in front of a field in a data declaration signifies
strictness.  In the example below, whenever we construct a value with
TT, the second argument is evaluated.

\begin{code}
data TT a b = TT a !b
\end{code}

Perhaps your instances will work correctly with this data declaration?


Cheers,
Spencer Janssen
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to