RE: Showing tuples

2000-05-09 Thread Chris Angus

Do you derive Show for MyData?

 -Original Message-
 From: Mike Jones [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2000 05:58
 To: [EMAIL PROTECTED]
 Subject: Showing tuples
 
 
 Hi,
 
 I am having trouble with Show and tuples.
 
 I have a data structure, say:
 
 data MyData = ...
 
 And a value, say:
 
 value = (MyData..., MyData..., MyData)
 
 Then try to:
 
 show value
 
 I get a compiler message from ghc 4.05 that says:
 
 No instance for `Show (MyData, MyData, MyData)...
 
 What is the best way to deal with this problem?
 
 Thanks,
 
 Mike
 
 




RE: Showing tuples

2000-05-09 Thread Mike Jones

Chris,

Yes, I do derive Show for MyData. I was surprised it did not work.

Mike

-Original Message-
From: Chris Angus [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 09, 2000 12:57 AM
To: 'Mike Jones'; [EMAIL PROTECTED]
Subject: RE: Showing tuples


Do you derive Show for MyData?

 -Original Message-
 From: Mike Jones [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2000 05:58
 To: [EMAIL PROTECTED]
 Subject: Showing tuples
 
 
 Hi,
 
 I am having trouble with Show and tuples.
 
 I have a data structure, say:
 
 data MyData = ...
 
 And a value, say:
 
 value = (MyData..., MyData..., MyData)
 
 Then try to:
 
 show value
 
 I get a compiler message from ghc 4.05 that says:
 
 No instance for `Show (MyData, MyData, MyData)...
 
 What is the best way to deal with this problem?
 
 Thanks,
 
 Mike
 
 






Re: Showing tuples

2000-05-09 Thread Sven Panne

Mike Jones wrote:
 Yes, I do derive Show for MyData. I was surprised it did not work.

Deriving works, but GHC currently only contains instance declarations
for tuples up to 5 elements, so you have to write you own boring
instances for larger ones.  *yawn*

Cheers,
   Sven
-- 
Sven PanneTel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen  Oettingenstr. 67
mailto:[EMAIL PROTECTED]D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne




RE: Showing tuples

2000-05-09 Thread Chris Angus

Mike ... try this ...extend it to however long tuples you have


data MyData = Foo | Bar deriving Show

main = print (Foo,Foo,Foo,Foo,Foo,Foo)

instance (Show tv1, Show tv2, Show tv3, Show tv4, Show tv5 , Show tv6) =
Show (tv1,tv2,tv3,tv4,
tv5,tv6) where
showsPrec p (v1,v2,v3,v4,v5,v6) = showChar '(' . shows v1 . showChar
',' .
 shows v2 . showChar
',' .
 shows v3 . showChar
',' .
 shows v4 . showChar
',' .
 shows v5 . showChar
',' .
 shows v6 . showChar
')'

instance (Read tv1, Read tv2, Read tv3, Read tv4, Read tv5 , Read tv6) =
Read (tv1,tv2,tv3,tv4,
tv5,tv6) where
readsPrec p = readParen False
(\s0 - [((v1,v2,v3,v4,v5,v6),s6A) | ("(",s1) - lex
s0,
   (v1,s1A) - reads
s1,
   (",",s2) - lex
s1A,
   (v2,s2A) - reads
s2,
   (",",s3) - lex
s2A,
   (v3,s3A) - reads
s3,
   (",",s4) - lex
s3A,
   (v4,s4A) - reads
s4,
   (",",s5) - lex
s4A,
   (v5,s5A) - reads
s5,
   (",",s6) - lex
s5A,
   (v6,s6A) - reads
s6,
   (")",s3) - lex
s2A ])



 -Original Message-
 From: Mike Jones [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2000 14:54
 To: 'Chris Angus'
 Cc: [EMAIL PROTECTED]
 Subject: RE: Showing tuples
 
 
 Chris,
 
 Yes, I do derive Show for MyData. I was surprised it did not work.
 
 Mike
 
 -Original Message-
 From: Chris Angus [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, May 09, 2000 12:57 AM
 To: 'Mike Jones'; [EMAIL PROTECTED]
 Subject: RE: Showing tuples
 
 
 Do you derive Show for MyData?
 
  -Original Message-
  From: Mike Jones [mailto:[EMAIL PROTECTED]]
  Sent: 09 May 2000 05:58
  To: [EMAIL PROTECTED]
  Subject: Showing tuples
  
  
  Hi,
  
  I am having trouble with Show and tuples.
  
  I have a data structure, say:
  
  data MyData = ...
  
  And a value, say:
  
  value = (MyData..., MyData..., MyData)
  
  Then try to:
  
  show value
  
  I get a compiler message from ghc 4.05 that says:
  
  No instance for `Show (MyData, MyData, MyData)...
  
  What is the best way to deal with this problem?
  
  Thanks,
  
  Mike
  
  
 
 
 




Showing tuples

2000-05-09 Thread grust




Hi,

I am having trouble with Show and tuples.

I have a data structure, say:

data MyData = ...

And a value, say:

value = (MyData..., MyData..., MyData)

Then try to:

show value

I get a compiler message from ghc 4.05 that says:

No instance for `Show (MyData, MyData, MyData)...

What is the best way to deal with this problem?

Thanks,

Mike







RE: Showing tuples

2000-05-09 Thread grust




Do you derive Show for MyData?

 -Original Message-
 From: Mike Jones [mailto:[EMAIL PROTECTED]]
 Sent: 09 May 2000 05:58
 To: [EMAIL PROTECTED]
 Subject: Showing tuples


 Hi,

 I am having trouble with Show and tuples.

 I have a data structure, say:

 data MyData = ...

 And a value, say:

 value = (MyData..., MyData..., MyData)

 Then try to:

 show value

 I get a compiler message from ghc 4.05 that says:

 No instance for `Show (MyData, MyData, MyData)...

 What is the best way to deal with this problem?

 Thanks,

 Mike








RE: Showing tuples

2000-05-09 Thread Mike Jones



Sven,

That explains it. My tuples are of size 20.

Thanks,

Mike


Deriving works, but GHC currently only contains instance declarations
for tuples up to 5 elements, so you have to write you own boring
instances for larger ones.  *yawn*

Cheers,
   Sven
-- 
Sven PanneTel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen  Oettingenstr. 67
mailto:[EMAIL PROTECTED]D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne





Showing tuples

2000-05-08 Thread Mike Jones

Hi,

I am having trouble with Show and tuples.

I have a data structure, say:

data MyData = ...

And a value, say:

value = (MyData..., MyData..., MyData)

Then try to:

show value

I get a compiler message from ghc 4.05 that says:

No instance for `Show (MyData, MyData, MyData)...

What is the best way to deal with this problem?

Thanks,

Mike