first post

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

first post

Chad Scherrer-2
Because the load function interacts with the outside world, its type
involves the IO monad. You can get the result you're looking for using
something like

liftM parse load

liftM takes an ordinary function and applies it to a monadic value (here
the monad is IO), returning another monadic value.

Or, if you're using ghci, you could just do

s <- load
parse s

This is because ghci executes "in the IO monad" (maybe there are some
details of this I'm missing, but that's how I think of it anyway.

BTW, your load function could be equivalently written simply as
load = readFile "parse.hs"

-Chad Scherrer

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe