Thu, 6 Apr 2000 12:15:26 -0700, Michael A. Jones <[EMAIL PROTECTED]> pisze:

> Second, perhaps you can suggest a place I can ask newbie questions
> that is more appropriate than this list.

IMHO this is good. For questions not related to GHC there is a parallel
haskell mailing list, and there is a newsgroup comp.lang.functional.

> Are there any papers/docs on debug techniques for debugging programs
> compiled under GHC?

I don't know any.

> Is there a way to force a statement in a let expression to evaluate
> and thus print text?

In GHC there is an unsafe function
    IOExts.trace :: String -> a -> a
which returns a value which, when evaluated, prints the given text
before evaluating the second argument of trace.

> I tried to perform IO in a let expression, but it seems that it wont
> evaluate if some other value does not depend on it, or execution
> never reached the let.

Well, laziness is exactly about this, and unfotunately it makes
conventional debugging techniques inappropriate.

Haskell's laziness includes the rule that mere evaluation of
an expression cannot cause any visible side effects other than
nontermination. An expression is evaluated only when its value is
needed to determine the value of another expression, and it was
evaluated only because... etc.

The fist rule ensures that you can always forget that there is laziness
(modulo efficiency issues). The second one ensures that the result
will be the same as for any other evaluation order, if the other
order would give any result at all; but there are cases where lazy
evaluation order does give a result and some other does not or does
it very inefficiently.

This has impact on interface to side effects. Thus I/O is normally done
differently. A function like trace breaks the spirit and theoretical
model of the language. It is included in GHC because it's convenient
for debugging (although I have almost never used it), but theoretically
it should not exist.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-


Reply via email to