Bjorn Lisper
data LispList t = Atom t | LispList [LispList t] | Str [Char]
instance Show t => Show (LispList t) where show (Atom t) = show t show (LispList t) = show t show (Str t) = show t
hugsprompt> (LispList [Atom 1, Str "HEJ"]) ==> [1,"HEJ"] hugsprompt> (LispList [Str "HEJ",Atom 1]) ==> "Cannot find show function...."
So there is a problem when the value is of form Str string or where such a value is first in the list l in a value of the form LispList l. Oddly enough, such values may appear at other positions without causing any problems.
Are you sure about that? I can't reproduce the above results in hugs (Hugs 98, February 2000) or ghci (5.02). I get a much simpler answer: if the s-expression includes an Atom term, it works; otherwise you get a type error. In particular, for the second example above (LispList [Str "HEJ", Atom 1]) both ghci and hugs produce the expected result, rather than failing. Carl Witty
participants (1)
-
cwitty@newtonlabs.com