How to catch and error message and how to make it create unix files instead of dos files??

Alexandre Weffort Thenorio thenorio@home.se
Sat, 1 Mar 2003 22:53:24 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C2E045.5D369A60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am trying to write a small software to take info from one file and =
write it into another file. The problem is that when I don't give any =
input I get the normal haskell nosuchfile error message but I want to =
give my own error message. I am a newbie, how can I do that? Also I need =
the file that is gonna be created (A text file), to be created in UNIX =
type and not as a DOS file type, how can I do that? I am using ghc to =
compile on Windows.

Here is the main code

main :: IO()
main =3D do
 args <- getArgs
 codes <- codes args
 conax <- readconax "conax.txt"
 makeIrdFile (lines codes) (lines conax)
 =20

--Read input file------------------------------------
codes :: [String] -> IO[Char]
codes [] =3D return ""
codes (x:xs) =3D do
 first <- readFile x
 return first
=20
--Read Inbuilt file---------------------------------
readconax file =3D do
 list <- readFile file
 return list
------=_NextPart_000_0017_01C2E045.5D369A60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am trying to write a small software =
to take info=20
from one file and write it into another file. The problem is that when I =
don't=20
give any input I get the normal haskell nosuchfile error message but I =
want to=20
give my own error message. I am a newbie, how can I do that? Also I need =
the=20
file that is gonna be created (A text file), to be created in UNIX type =
and not=20
as a DOS file type, how can I do that? I am using ghc to compile on=20
Windows.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here is the main code</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>main :: IO()<BR>main =3D =
do<BR>&nbsp;args &lt;-=20
getArgs<BR>&nbsp;codes &lt;- codes args<BR>&nbsp;conax &lt;- readconax=20
"conax.txt"<BR>&nbsp;makeIrdFile (lines codes) (lines=20
conax)<BR>&nbsp;&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--Read input=20
file------------------------------------<BR>codes :: [String] -&gt;=20
IO[Char]<BR>codes [] =3D return ""<BR>codes (x:xs) =3D do<BR>&nbsp;first =
&lt;-=20
readFile x<BR>&nbsp;return first<BR>&nbsp;<BR>--Read Inbuilt=20
file---------------------------------<BR>readconax file =3D =
do<BR>&nbsp;list &lt;-=20
readFile file<BR>&nbsp;return list</FONT></DIV></BODY></HTML>

------=_NextPart_000_0017_01C2E045.5D369A60--