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

Hal Daume III hdaume@ISI.EDU
Sun, 2 Mar 2003 15:13:20 -0800 (PST)


main = do
  v <- try $ readFile "foo"
  case v of
    Left _ -> putStrLn "an error occurred"
    Right t -> putStrLn t

should work

--
 Hal Daume III                                   | hdaume@isi.edu
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume

On Sun, 2 Mar 2003, Alexandre Weffort Thenorio wrote:

> Thanks I actually have done that but couldn't understand how to use them.
> Can you give me an example on a function that reads a file and in case the
> file is not found you throw a string like "File not found" or so??
> 
> Best Regards
> 
> NooK
> 
> ----- Original Message -----
> From: "Hal Daume III" <hdaume@ISI.EDU>
> To: "Alexandre Weffort Thenorio" <thenorio@home.se>
> Cc: <haskell@haskell.org>
> Sent: Sunday, March 02, 2003 3:11 AM
> Subject: Re: How to catch and error message and how to make it create unix
> files instead of dos files??
> 
> 
> > Look at the functions try catch and bracket.
> >
> > --
> >  Hal Daume III                                   | hdaume@isi.edu
> >  "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume
> >
> > On Sat, 1 Mar 2003, Alexandre Weffort Thenorio wrote:
> >
> > > 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 = do
> > >  args <- getArgs
> > >  codes <- codes args
> > >  conax <- readconax "conax.txt"
> > >  makeIrdFile (lines codes) (lines conax)
> > >
> > >
> > > --Read input file------------------------------------
> > > codes :: [String] -> IO[Char]
> > > codes [] = return ""
> > > codes (x:xs) = do
> > >  first <- readFile x
> > >  return first
> > >
> > > --Read Inbuilt file---------------------------------
> > > readconax file = do
> > >  list <- readFile file
> > >  return list
> >
> > _______________________________________________
> > Haskell mailing list
> > Haskell@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell
> >
> 
> _______________________________________________
> Haskell mailing list
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>