Error in Haskell 98 Report 'lex' function
Simon Peyton-Jones
simonpj@microsoft.com
Mon, 10 Feb 2003 12:25:28 -0000
This is a multi-part message in MIME format.
--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C2D0FF.7EBEC6A8"
------_=_NextPart_001_01C2D0FF.7EBEC6A8
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
Ah yes, this is a genuine bug. Haskell 98 changed at some point to
allow identifiers and field labels with a leading '_', but the library
didn't keep pace.
=20
I'll fix GHC. =20
=20
HOWEVER, the sad thing is that the same bug is in the Haskell 98 Report
itself, now begin printed. The definition of lex is wrong. =20
=20
Ah well, I knew this would happen. I'd better start keeping a new bug
list!
=20
Simon
=20
=20
-----Original Message-----
From: Jong Keun Na [mailto:jongkn@microsoft.com]=20
Sent: 10 February 2003 02:48
To: Simon Peyton-Jones; haskell-cafe@haskell.org
Subject: RE: Auto generated instance codes through 'deriving'
=20
The following code snippet not works correctly.
=20
>data Obj =3D Obj {_id, p1, p2::Int} deriving (Show, Read)
=20
>showObj :: Obj -> String
>showObj o =3D show o
=20
>main =3D do print (showObj (read "Obj {_id=3D1,p1=3D10,p2=3D20}"))
> return ()
=20
The reason is because I used the property name with underscore char like
"_id".
Looking into auto generated class codes and seeing they show it should
encompass identifiers with special characters with parenthesis, so I
tried "Obj {(_id)=3D1,p1=3D10,p2=3D20}" as argument of read func. But, =
the
result is same, parse error.
=20
Is this problem by-design or bug? Or Am I missing any point?
=20
Thanks,
/JongKeun
=20
=20
-----Original Message-----
From: Simon Peyton-Jones=20
Sent: Friday, February 07, 2003 5:41 PM
To: Jong Keun Na; haskell-cafe@haskell.org
Subject: RE: Auto generated instance codes through 'deriving'
=20
Try -ddump-deriv
=20
http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/options-debu
gging.html#DUMPING-OUTPUT
=20
Simon
=20
-----Original Message-----
From: Jong Keun Na [mailto:jongkn@microsoft.com]=20
Sent: 07 February 2003 06:15
To: haskell-cafe@haskell.org
Subject: Auto generated instance codes through 'deriving'
=20
Hello folks,
Is there any method with which I can see instance's codes generated
automatically by using 'deriving' keyword in GHC?
I'm curious in how GHC generates 'Read' class's instance code for
user-defined data type.
Any help will be great appreciated.
/JongKeun
------_=_NextPart_001_01C2D0FF.7EBEC6A8
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<title>Auto generated instance codes through 'deriving'</title>
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
p
{margin-right:0cm;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman";}
span.emailstyle18
{font-family:Arial;
color:navy;}
span.emailstyle19
{font-family:Tahoma;
color:blue;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
span.EmailStyle20
{font-family:Arial;
color:navy;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-GB link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><!-- Converted from text/rtf format =
-->Ah
yes, this is a genuine bug. Haskell 98 changed at some point =
to
allow identifiers and field labels with a leading ‘_’, but =
the
library didn’t keep pace.</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I’ll fix GHC. =
</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>HOWEVER, the sad thing is that the =
same
bug is in the Haskell 98 Report itself, now begin printed. The =
definition
of lex is wrong. </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Ah well, I knew this would =
happen. I’d
better start keeping a new bug list!</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Simon</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>
<div style=3D'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm =
0cm 4.0pt'>
<p class=3DMsoNormal><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Jong Keun Na
[mailto:jongkn@microsoft.com] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> 10 February 2003 =
02:48<br>
<b><span style=3D'font-weight:bold'>To:</span></b> Simon Peyton-Jones;
haskell-cafe@haskell.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: Auto =
generated
instance codes through 'deriving'</span></font></p>
<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>The following =
code
snippet not works correctly.</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>>data Obj =
=3D Obj {_id,
p1, p2::Int} deriving (Show, Read)</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>>showObj :: =
Obj ->
String</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>>showObj o =
=3D show o</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>>main =3D do =
print
(showObj (read "Obj =
{_id=3D1,p1=3D10,p2=3D20}"))</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>> =
return ()</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>The reason is =
because I
used the property name with underscore char like =
“_id”.</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>Looking into =
auto
generated class codes and seeing they show it should encompass =
identifiers with
special characters with parenthesis, so I tried "Obj
{(_id)=3D1,p1=3D10,p2=3D20}" as argument of read func. But, the =
result is same,
parse error.</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>Is this problem
by-design or bug? Or Am I missing any point?</span></font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>Thanks,</span></=
font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'>/JongKeun</span>=
</font></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal><font size=3D2 color=3Dblue face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma;color:blue'> </span></f=
ont></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Simon Peyton-Jones =
<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Friday, February =
07, 2003
5:41 PM<br>
<b><span style=3D'font-weight:bold'>To:</span></b> Jong Keun Na;
haskell-cafe@haskell.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: Auto =
generated
instance codes through 'deriving'</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D3
face=3D"Times New Roman"><span lang=3DEN-US =
style=3D'font-size:12.0pt'> </span></font></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Try
-ddump-deriv</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>  =
;
http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/options-debug=
ging.html#DUMPING-OUTPUT</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'> </span></fo=
nt></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Simon</span></fon=
t></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'> </span></fo=
nt></p>
<div style=3D'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm =
0cm 4.0pt'>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Jong Keun Na
[mailto:jongkn@microsoft.com] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> 07 February 2003 =
06:15<br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
haskell-cafe@haskell.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Auto generated =
instance
codes through 'deriving'</span></font></p>
<p class=3DMsoNormal style=3D'margin-left:39.95pt'><font size=3D3
face=3D"Times New Roman"><span =
style=3D'font-size:12.0pt'> </span></font></p>
<p style=3D'margin-left:39.95pt'><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'>Hello =
folks,</span></font></p>
<p style=3D'margin-left:39.95pt'><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'>Is there any =
method</span></font><span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>with which I can see</span></font><span =
lang=3DEN-US> </span><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>instance’s</span></fo=
nt><span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>codes</span></font><span lang=3DEN-US> =
</span><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>generated
automatically</span></font><span lang=3DEN-US> </span><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US style=3D'font-size:10.0pt;font-family:Tahoma'>by =
using</span></font><span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>‘<b><span =
style=3D'font-weight:bold'>deriving’</span></b>
keyword in GHC?</span></font></p>
<p style=3D'margin-left:39.95pt'><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'>I’m curious in how =
GHC
generates</span></font><span lang=3DEN-US> </span><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>‘<b><span
style=3D'font-weight:bold'>Read’</span></b></span></font><span =
lang=3DEN-US> </span><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>class’s</span></font>=
<span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>instance code for</span></font><span =
lang=3DEN-US> </span><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>user-defined</span></font><=
span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>data type.</span></font></p>
<p style=3D'margin-left:39.95pt'><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'>Any</span></font><span =
lang=3DEN-US> </span><font
size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>help
will be</span></font><span lang=3DEN-US> </span><font size=3D2 =
face=3DTahoma><span
lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Tahoma'>great</span></font><span
lang=3DEN-US> </span><font size=3D2 face=3DTahoma><span lang=3DEN-US =
style=3D'font-size:
10.0pt;font-family:Tahoma'>appreciated.</span></font></p>
<p style=3D'margin-left:39.95pt'><font size=3D2 face=3DTahoma><span =
lang=3DEN-US
style=3D'font-size:10.0pt;font-family:Tahoma'>/JongKeun</span></font></p>=
</div>
</div>
</div>
</body>
</html>
------_=_NextPart_001_01C2D0FF.7EBEC6A8--
--------------InterScan_NT_MIME_Boundary--