Attached are two programs, both of which are supposed to print a string.
Long.hs looks fairly simple to me. However when compiled with
ghc -O2, I get a segmentation fault:
> ghc Long.hs -o long -O2
> ./long
> Segmentation Fault
With ghc -O or ghc it works. I suppose this is probably a memory
problem so if you can't reproduce it try replacing 200 by something a
little higher.
ABC.hs is a little more complicated (it generates an infinite string
of ABCs containing no consecutive equal sequences). Whatever I do
(ghc, ghc -O or ghc -O2) it falls over with:
Fail: resource exhausted
Action: writeChunks
Reason: insufficient resources
after printing a measly 9216 characters. Maybe I deserve this, but I
think the message could be a little more helpful.
So what is going on?
Long.hs
ABC.hs