<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>ghci and applicative</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hi,<BR>
<BR>
I'm finding that some data types which use Applicative to<BR>
instantiate the Num class, give responses I wasn't expecting<BR>
at the ghci prompt. A simple example is list:<BR>
<BR>
import Control.Applicative<BR>
<BR>
instance (Num a) =&gt; Num [a] where<BR>
&nbsp;as + bs = (+) &lt;$&gt; as &lt;*&gt; bs<BR>
&nbsp;(*) = undefined;&nbsp;&nbsp;&nbsp; abs = undefined<BR>
&nbsp;signum = undefined; fromInteger = undefined<BR>
<BR>
f1 = let op = (+) in [1,2,3] `op` [1,1,1]<BR>
f2 = let op = (+) in op [1,2,3] [1,1,1]<BR>
<BR>
Functions f1 and f2 give no problems at the ghci prompt.<BR>
However if I instead type the body of either interactively,<BR>
I get an error:<BR>
<BR>
*Main&gt; let op = (+)<BR>
*Main&gt; [1,2,3] `op` [1,1,1]<BR>
<BR>
&lt;interactive&gt;:1:0:<BR>
&nbsp;&nbsp;&nbsp; Couldn't match expected type `Integer' against inferred type `[a]'<BR>
&nbsp;&nbsp;&nbsp; In the first argument of `op', namely `[1, 2, 3]'<BR>
&nbsp;&nbsp;&nbsp; In the expression: [1, 2, 3] `op` [1, 1, 1]<BR>
&nbsp;&nbsp;&nbsp; In the definition of `it': it = [1, 2, 3] `op` [1, 1, 1]<BR>
<BR>
I get the same error message with op [1,2,3] [1,1,1]. Any thoughts?<BR>
<BR>
Thanks,<BR>
Paul</FONT>
</P>

</BODY>
</HTML>