<!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) => Num [a] where<BR>
as + bs = (+) <$> as <*> bs<BR>
(*) = undefined; abs = undefined<BR>
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> let op = (+)<BR>
*Main> [1,2,3] `op` [1,1,1]<BR>
<BR>
<interactive>:1:0:<BR>
Couldn't match expected type `Integer' against inferred type `[a]'<BR>
In the first argument of `op', namely `[1, 2, 3]'<BR>
In the expression: [1, 2, 3] `op` [1, 1, 1]<BR>
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>