[Haskell] Re: IO functions reference?

Creighton Hogg wchogg at lotus.hep.wisc.edu
Tue Sep 27 10:48:14 EDT 2005

On Tue, 27 Sep 2005, Ketil Malde wrote:

> Creighton Hogg <wchogg at lotus.hep.wisc.edu> writes:
> > So I looked to see if there were any standard functions for 
> > taking an input line and turning it into a list, and I 
> > couldn't find any.  How would one do this in Haskell?  I 
> > just want to parse the line into a list of strings, and 
> > from there recover the numbers from the strings.
> In other words, you want to split "lines" into "words" and "read"
> numbers from the result?  Perhaps you should check the Prelude again.

Well don't I feel silly.  I'll RTFM next time instead of 
just skimming the type signatures.
> > That doesn't seem easy though, unelss there's something I'm 
> > missing.
> Reading from and writing to the outside world must take place in the
> IO monad.  The parsing and other manipulation can be done by
> functions, use e.g. "let" in the IO code to construct intermediate
> values. 
> E.g., main can look like:
> main = do
>      f <- readFile "table.txt"
>      let x = my_parse_function f
>      putStrLn x
> my_parse_function :: String -> String
> ...

Okay this is a bit more clear to me now, thanks.

More information about the Haskell mailing list