problems with ghc ffi
Simon Peyton-Jones
simonpj@microsoft.com
Mon, 4 Nov 2002 14:41:09 -0000
This is a multi-part message in MIME format.
--------------InterScan_NT_MIME_Boundary
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C28410.36EF7DCD"
------_=_NextPart_001_01C28410.36EF7DCD
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
GHC questions to ghc-users please, not the main Haskell list.
=20
You need the -ffi flag to use the FFI.
S
=20
-----Original Message-----
From: David Abbs [mailto:u0da2@dcs.shef.ac.uk]=20
Sent: 04 November 2002 14:38
To: haskell@haskell.org
Subject: problems with ghc ffi
=20
I am having problems with the GHC FFI, I am using GHC version 5.04.1 and
am trying to compile the sample code given on=20
the web site
_______________________________________
module Foo where
=20
foreign export ccall foo :: Int -> IO Int
=20
foo :: Int -> IO Int
foo n =3D return (length (f n))
=20
f :: Int -> [Int]
f 0 =3D []
f n =3D n:(f (n-1))
_____________________________________
when I enter
c:/ghc M.hs=20
to compile the code I get the following error
M.hs:5: Type signature given for an expression
I have tried compiling the code using GHC 5.04.1 on windows 98, XP and
on Linux any help on would be=20
greatly appreciated.
_____________________________________________
David Abbs 3rd year Undergraduate in Computer Science=20
at the University Of Sheffield
_____________________________________________
u0da2@dcs.shef.ac.uk
Have a very nice day !!
=20
------_=_NextPart_001_01C28410.36EF7DCD
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//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)">
<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:blue;
text-decoration:underline;}
pre
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle18
{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 bgcolor=3Dwhite lang=3DEN-GB link=3Dblue vlink=3Dblue>
<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'>GHC questions to ghc-users please, =
not the
main Haskell 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'>You need the -ffi flag to use the =
FFI.</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'><br>
S</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> David Abbs
[mailto:u0da2@dcs.shef.ac.uk] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> 04 November 2002 =
14:38<br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
haskell@haskell.org<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> problems with =
ghc ffi</span></font></p>
<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'> </span></font></p>
<div><pre><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:
Arial'>I am having problems with the GHC FFI, I am using GHC version =
5.04.1 and am trying to compile the sample code given on =
</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>the web =
site</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>____________________________=
___________</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>module Foo =
where</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'> </span></font></pre><p=
re><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>foreign export ccall foo :: =
Int -> IO Int</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'> </span></font></pre><p=
re><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>foo :: Int -> IO =
Int</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>foo n =3D return (length (f =
n))</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'> </span></font></pre><p=
re><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>f :: Int -> =
[Int]</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>f 0 =3D =
[]</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>f n =3D n:(f =
(n-1))</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>____________________________=
_________</span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>when I =
enter</span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>c:/ghc =
M.hs </span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>to =
compile the code I get the following error</span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>M.hs:5: =
Type signature given for an expression</span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span style=3D'font-size:10.0pt'>I have =
tried compiling the code using GHC </span></font><font
face=3DArial><span style=3D'font-family:Arial'>5.04.1 on windows 98, XP =
and on Linux any help on would be </span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>greatly =
appreciated.</span></font></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>____________________________=
_________________<br>
David Abbs 3rd year Undergraduate in Computer Science <br>
at the University Of Sheffield<br>
_____________________________________________<br>
<a =
href=3D"mailto:u0da2@dcs.shef.ac.uk">u0da2@dcs.shef.ac.uk</a></span></fon=
t></pre><pre><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>Have a very nice day =
!!</span></font></pre><pre><font
size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt'> </span></font></pre></div>
</div>
</div>
</body>
</html>
------_=_NextPart_001_01C28410.36EF7DCD--
--------------InterScan_NT_MIME_Boundary--