Re: Strange error in show for datatype

2001-10-03 Thread Carl R. Witty
Bjorn Lisper <[EMAIL PROTECTED]> writes: > 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"]) ==> [

Re: Strange error in show for datatype

2001-10-03 Thread Thomas Hallgren
Simon Peyton-Jones wrote: >... > msg :: forall a. Show a => String > >Urk! What "Show" dictionary should Hugs use when evaluating "msg"? > >You may say "it doesn't matter", but in general that's not the case. >In the case of class Num, for example, we might have > > expr = 3+4 >

BOFH's excuse board

2001-10-03 Thread Duncan Coutts
Hi all, I though you might apreciate this: I've been reading the BOFH (Bastard Operator From Hell) serialisation in The Register (www.theregister.co.uk) far to much recently. He (the bastard) often uses his excuse board to confuse his helpless users. http://bofh.ntk.net/ExcuseBoard.html I hav

RE: Strange error in show for datatype

2001-10-03 Thread Jan-Willem Maessen
"Simon Peyton-Jones" <[EMAIL PROTECTED]> tries his hand at inventing free theorems for qualified types, then concludes: > In which case we could report ambiguity a bit less often. How > useful this would be I don't know. A lot. Any time one is testing the empty case of a bulk type. If you're c

RE: Strange error in show for datatype

2001-10-03 Thread Simon Peyton-Jones
Interesting. The difficulty (which GHCi has too) is this. Consider expr = Str "foo" msg = show expr Hugs wants to print msg. What are the types? expr :: forall a. LispList a msg :: forall a. Show a => String Urk! What "Show" dictionary should Hugs use when e

Re: Strange error in show for datatype

2001-10-03 Thread John Peterson
This problem is probably caused by the unbound type variable in values like (Str "HEJ"). Try giving a specific type as the parameter to LispList: (Str "HEJ" :: LispList Int) The error message here could me more informative! John ___ Haskell mailin

Strange error in show for datatype

2001-10-03 Thread Bjorn Lisper
Hi, For a change, a teacher asking for help on behalf of a student I have a student who wants to emulate S-expressions of Lisp in Haskell. He came up with the following data type: data LispList t = Atom t | LispList [LispList t] | Str [Char] This works just fine. He then wanted to make it