[cvs-nhc98] Support newtype data constructors and ~ in -T tracing vers

User olaf olaf@sparud.net
Wed, 13 Feb 2002 17:03:34 +0100 (CET)


olaf: Wed Feb 13 17:03:33 CET 2002

Update of /usr/src/master/nhc/src/compiler98
In directory hinken:/tmp/cvs-serv20974/src/compiler98

Modified Files:
	DbgTrans.hs Info.hs 
Log Message:
Support newtype data constructors and ~ in -T tracing version.

The traced code used to be more strict than it should be in arguments of constructors of newtypes and variables occuring in ~ patterns.
Variables in irrefutable patterns may never be evaluated. Hence these variables need to be treated as let not as lambda bound.

Now before actual trace transformation replace every irrefutable pattern in a refutable pattern by a new variable and add an appropriate pattern binding. This leads to a tracing program with the original strictness. The created trace is basically right, except that the newly introduced variable appears in the trace. This is because I reused the normal transformation of pattern bindings; to obtain the desired trace special handling would be necessary. Then change from lambda to let-bound variables is a bit of a hack.

Still need to do something similar in the portable version.


Example program that did not work before:

newtype Seq a = Seq ([a] -> [a])

(+++) :: Seq a -> Seq a -> Seq a
(Seq fxs) +++ (Seq fys) = Seq (fxs . fys)

left (Seq fxs) = head (fxs [])

main = print (left (Seq (True:) +++ undefined))