IO functions reference?
Hi, I've been trying to write some code in Haskell and have been running into trouble not knowing the already built-in IO functions. For example, is there a function that will take a line and turn it into a list? Is there a reference where one can lookup all these things? Thanks, Creighton Hogg
On Mon, Sep 26, 2005 at 10:19:09AM -0500, Creighton Hogg <wchogg@lotus.hep.wisc.edu> wrote a message of 13 lines which said:
Is there a reference where one can lookup all these things?
I use: http://www.zvon.org/other/haskell/Outputglobal/index.html
On Mon, 26 Sep 2005, Stephane Bortzmeyer wrote:
On Mon, Sep 26, 2005 at 10:19:09AM -0500, Creighton Hogg <wchogg@lotus.hep.wisc.edu> wrote a message of 13 lines which said:
Is there a reference where one can lookup all these things?
I use:
I appreciate all the references people gave. 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. Basically, my goal is to take a table of floats, read it in line by line and store it into a list of lists, then run the whole thing through a function and print the output. That doesn't seem easy though, unelss there's something I'm missing.
Creighton Hogg <wchogg@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.
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 ... -k -- If I haven't seen further, it is by standing in the footprints of giants
On Tue, 27 Sep 2005, Ketil Malde wrote:
Creighton Hogg <wchogg@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.
On 26/09/05, Creighton Hogg <wchogg@lotus.hep.wisc.edu> wrote:
Hi, I've been trying to write some code in Haskell and have been running into trouble not knowing the already built-in IO functions. For example, is there a function that will take a line and turn it into a list? Is there a reference where one can lookup all these things?
Thanks, Creighton Hogg
Well, the standard prelude is the first thing to read: http://www.haskell.org/onlinereport/standard-prelude.html Then refer to the standard libraries: http://www.haskell.org/ghc/docs/latest/html/libraries/index.html for lots more. Also in Part II of the report, there's further documentation for some of the libraries (though they have been moved into the hierarchy). http://www.haskell.org/onlinereport/
participants (4)
-
Cale Gibbard -
Creighton Hogg -
Ketil Malde -
Stephane Bortzmeyer