[Haskell-beginners] Multiline code in GHCi

Shishir Srivastava shishir.srivastava at gmail.com
Fri Aug 7 15:15:11 UTC 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150807/c23b059c/attachment.html>


More information about the Beginners mailing list