Gene Arthur
unread,Feb 7, 2015, 1:52:48 PM2/7/15You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
quick and dirty way, define putStrLnIO = (=>> putStrLn) in ghci and then:
putStrLnIO . getline
Being you are new what is happening is that >>= is the bind operator and since IO is a monad, you are by binding/lifting the StringIO value into the internal world of the IO monad where the value is dropped down to it's base type of String and a regular old putStrLn can be used. Another way of looking at is that the StringIO is lifted into the context of the container monad, so there is besides that weird looking operator >>= , you also have a function, liftM that you may use in the definition of putStrLnIO:
putStrLnIO = liftM putStrLn
You can do this raw without defining new functions:
getline >>= putStrLn
OR
liftM putStrLn . getline
My hope is that you will try these and also look at the 'do notation way of doing this too.' leave that for another commenter that likes more verbage and pseudo variables, and pointed rather point free function definitions.
cheers gene