[Haskell-beginners] Multiline code in GHCi
Brandon Allbery
allbery.b at gmail.com
Fri Aug 7 15:51:00 UTC 2015
On Fri, Aug 7, 2015 at 11:15 AM, Shishir Srivastava <
shishir.srivastava at gmail.com> wrote:
> 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 an actual program, it would be able to apply defaulting rules and
monomorphize `b0` to Integer. The somewhat unusual ghci environment, in
particular how it tries to figure out whether to evaluate an expression and
`print` the result or instead run an IO action --- coupled with the
monomorphism restriction being disabled in the interactive context in ghci
7.8 and later --- is working against you here. As a result, you need to
specify a result type when invoking `main1`, which is what the error
message is telling you.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150807/1be5caf8/attachment.html>
More information about the Beginners
mailing list