[Haskell-cafe] Re: A GHC error message puzzle

Wei Hu wei.hoo at gmail.com
Thu Aug 12 16:54:44 EDT 2010


Threaded or not doesn't seem to make a difference. I just noticed with
optimization turned on, RTS does detect the loop.

On Thu, Aug 12, 2010 at 4:28 PM, Jason Dagit <dagit at codersbase.com> wrote:
>
>
> On Thu, Aug 12, 2010 at 1:25 PM, Wei Hu <wei.hoo at gmail.com> wrote:
>>
>> Anyone care to explain why? I also tested a slightly changed program
>> pasted below, and am very confused.
>>
>> > main = do
>> >   -- This call doesn't terminate, why?
>> >   print $ nonTermination "a"
>> >   -- Comment the above line to test the rest of the code
>> >   -- RTS detects the loop and bails out
>> >   print $ process "abc"
>> >   -- Comment the above line to test the rest of the code
>> >   inp <- readFile "input"
>> >   -- I'm guessing (process inp) throws an exception,
>> >   -- and the handler closes all files, making a second close fail?
>> >   writeFile "output" $ process inp
>>
>> > process :: String ->  String
>> > process xs = blackhole where blackhole = tail blackhole
>>
>> > nonTermination :: String -> String
>> > nonTermination _ = blackhole where blackhole = blackhole
>
> If you compile the program to use the non-threaded RTS does the behavior
> change?
> Jason


More information about the Haskell-Cafe mailing list