Re: hat error with HUnit: Variable not in scope: `TPrelude.fnegate'

Malcolm Wallace <[email protected]>
Newsgroups gmane.comp.lang.haskell.hat
Organization Dept of Computer Science, University of York, UK.
Message-ID <[email protected]>
Shae Matijs Erisson <[email protected]> writes:

> I'm using HUnit (http://hunit.sf.net/)
> 
> /home/shae/src/haskell/libraries/THUnitText.hs:64:
>     Variable not in scope: `TPrelude.fnegate'

The problem here is with hat-trans - in the following definition,

    put line pers (-1) = do ...; return (-1)

it has mistakenly interpreted the negative number literal on the left
hand side as a variable binding for negate.  Hence, in the transformed
version of the code, it has used the lambda-bound form `fnegate'
on the right, instead of the real let-bound variable `gnegate'.

Until we can find a fix for hat-trans, here is a workaround for your
application.  Replace the negative numeric literal pattern with another
form, such as a guard.  For instance:

--- HUnitText.lhs	Thu Feb 21 20:21:13 2002
+++ HUnitText.lhs.new	Fri Jul 26 10:43:40 2002
@@ -55,7 +55,8 @@
 > putTextToHandle handle showProgress = PutText put initCnt
 >  where
 >   initCnt = if showProgress then 0 else -1
->   put line pers (-1) = do when pers (hPutStrLn handle line); return (-1)
+>   put line pers  cnt | cnt == (-1)
+>                      = do when pers (hPutStrLn handle line); return (-1)
 >   put line True  cnt = do hPutStrLn handle (erase cnt ++ line); return 0
 >   put line False cnt = do hPutStr handle ('\r' : line); return (length line)
 >     -- The "erasing" strategy with a single '\r' relies on the fact that the

Regards,
    Malcolm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.