error function is not lazy
C:\Neil\Temp>type Test.hs main = error $ cycle "Hello\n" C:\Neil\Temp>ghc --make Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Linking Test.exe ... C:\Neil\Temp>test -- hangs forever
The error message seems to get buffered, which means long/infinite messages are never displayed. GHCi does evaluate error lazily. The error function is particularly useful for debugging, which is where I encountered this problem.
It appears trace has a similar issue of buffering in GHC compiled programs, but I am not certain.