Hi Shishir,

If you wrap multiline code in between 

Prelude> :{
Prelude|      let main1 = do
Prelude|                    a <- getLine
Prelude|                    return a
Prelude| :}
Prelude> main1
hello
"hello"
It will work.


On Fri, Aug 7, 2015 at 8:45 PM, Shishir Srivastava <shishir.srivastava@gmail.com> wrote:
Hi, 

I am trying to run this basic multiline code in GHCi. I am not sure if this is even possible without writing it in a file and compiling it in a traditional way. 

-------
Prelude> :set +m
Prelude> let main1 = do
Prelude|             a <- readLn
Prelude|             return a
Prelude|
Prelude>
Prelude> main1

<interactive>:75:1:
    No instance for (Show (IO b0)) arising from a use of `print'
    In the first argument of `print', namely `it'
    In a stmt of an interactive GHCi command: print it
-------

Could someone please confirm if the function can be defined and called like this in GHCi or point to where am going wrong.

Thanks,
Shishir Srivastava


_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners