To whom it may concern:

I am using Hugs98 (september release) together with the pretty printer
combinators by Hughes and Jones.
When printing a large structure, Hugs aborts with the message GC
Blackhole. The program works fine for smaller structures.
The problem occurs with all renderes.
I am quite sure that this is a pretty printing problem because the program
works fine when using a simple derived Show instance.
The problem occurs with ghc 4.05 , too. When printing a large structure,
the program crashes due to a bus error.

In order to reproduce the error you will need the complete package
including test data. (I could not reproduce the error by command-line
generated test data.) I will send a tar.gz file on demand.

I attached the module which makes use of the combinators. Maybe there is
an error.


Thank you,
Michael Marte







module Prolog(Term(..), Fact(..)) where
import Pretty
import List

data Term =
     Atom String |
     Int Int |
     Var String |
     AnonVar |
     Tuple [Term] |
     List [Term] |
     Set [Term] |
     Struct String [Term]

newtype Fact = Fact Term

instance Show Term where
    show t = show (pretty t)

instance Show Fact where
     show (Fact t) = show ((pretty t) <> (text "."))

pretty (Atom a) = text a
pretty (Int i) = int i
pretty (Var id) = text id
pretty AnonVar = text "_"
pretty (Tuple ts) = parens (fsep (punctuate comma (map pretty ts)))
pretty (List ts) = brackets (fsep (punctuate comma (map pretty ts)))
pretty (Set ts) = braces (fsep (punctuate comma (map pretty ts)))
pretty (Struct f ts) = (text f) <> (parens (sep (punctuate comma (map pretty ts))))

oneLineProlog :: Doc -> String
oneLineProlog d = fullRender OneLineMode 0 0 stringHandler "" d

stringHandler :: TextDetails -> String -> String
stringHandler (Chr c)   s  = c:s
stringHandler (Str s1)  s2 = s1 ++ s2
stringHandler (PStr s1) s2 = s1 ++ s2

Reply via email to