Hugs implicit parameters bug

Conal Elliott conal@microsoft.com
Wed, 6 Feb 2002 15:21:31 -0800


This is a multi-part message in MIME format.

--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C1AF65.02876415"

------_=_NextPart_001_01C1AF65.02876415
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Dec 2001 Hugs balks at the following simple program, while ghc 5.02.1
likes it just fine.

=20

    module Tst where

    t1 :: (Num a) =3D> Int -> ((?z :: Int) =3D> a) -> a

    t1 w imp =3D imp with ?z =3D w

=20

The Hugs error message:

=20

    ERROR "f:/Shader/tst.hs":3 - Inferred type is not general enough

    *** Expression    : t1

    *** Expected type : Num a =3D> Int -> ((?z :: Int) =3D> a) -> a

    *** Inferred type : Num Int =3D> Int -> ((?z :: Int) =3D> a) -> Int

=20

I can eliminate the error message by making the function be monomorphic
or by eliminating the first argument and using a numeric literal, i.e.,
hugs likes the following just fine:

=20

    t2 :: Int -> ((?z :: Int) =3D> String) -> String

    t2 w imp =3D imp with ?z =3D w

=20

    t3 :: (Num a) =3D> ((?z :: Int) =3D> a) -> a

    t3 imp =3D imp with ?z =3D 3

=20

    - Conal

=20


------_=_NextPart_001_01C1AF65.02876415
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html>

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">

<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	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;}
span.EmailStyle17
	{font-family:Arial;
	color:windowtext;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>Dec 2001 Hugs balks at the following simple =
program,
while ghc 5.02.1 likes it just fine.</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; module Tst =
where</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t1 :: (Num a) =3D&gt; Int =
-&gt;
((?z :: Int) =3D&gt; a) -&gt; a</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t1 w imp =3D imp with ?z =
=3D w</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>The Hugs error message:</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; ERROR
&quot;f:/Shader/tst.hs&quot;:3 - Inferred type is not general =
enough</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; *** =
Expression&nbsp;&nbsp;&nbsp;
: t1</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; *** Expected type : Num a =
=3D&gt;
Int -&gt; ((?z :: Int) =3D&gt; a) -&gt; a</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; *** Inferred type : Num =
Int =3D&gt;
Int -&gt; ((?z :: Int) =3D&gt; a) -&gt; Int</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>I can eliminate the error message by making =
the
function be monomorphic or by eliminating the first argument and using a =
numeric
literal, i.e., hugs likes the following just fine:</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t2 :: Int -&gt; ((?z :: =
Int)
=3D&gt; String) -&gt; String</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t2 w imp =3D imp with ?z =
=3D w</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t3 :: (Num a) =3D&gt; ((?z =
:: Int)
=3D&gt; a) -&gt; a</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; t3 imp =3D imp with ?z =3D =
3</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;&nbsp;&nbsp; - Conal</span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Courier New"><span =
style=3D'font-size:12.0pt;
font-family:"Courier New"'>&nbsp;</span></font></p>

</div>

</body>

</html>
=00
------_=_NextPart_001_01C1AF65.02876415--

--------------InterScan_NT_MIME_Boundary--