Why WinGHCi does not complain with no import?

I created my own version of getLine like this: getLine' :: IO String getLine' = do x <- getChar if x == '\n' then return [] else do xs <- getLine' return (x:xs) Basically I created a new file called test.hs and copied above code into it. I opened WinGHCi afresh and :load test.hs I can run getLine' in WinGHCi with no problem. But how does WinGHCi know about getChar and IO? I assumed I would have to import like this: import System.IO Is it because WinGHCi does this import for me? If I write this program and invoke using runghci: getLine' :: IO String getLine' = do x <- getChar if x == '\n' then return [] else do xs <- getLine' return (x:xs) main = do getLine' It also works without complaining. Is there a list of built-in libraries? Is that platform dependent?

On Tue, Jan 07, 2014 at 01:58:37PM +0000, Angus Comber wrote:
I can run getLine' in WinGHCi with no problem. But how does WinGHCi know about getChar and IO?
getChar is defined in the Prelude [1] (and the Prelude gets imported by default in every program/module) [1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:ge...

Hi Angus, On Tue, Jan 07, 2014 at 01:58:37PM +0000, Angus Comber wrote:
Is it because WinGHCi does this import for me?
It's defined by the Haskell standard, that you're automatically getting the 'Prelude' module: http://haddocks.fpcomplete.com/fp/7.4.2/20130829-168/base/Prelude.html Greetings, Daniel
participants (3)
-
Angus Comber
-
Daniel Trstenjak
-
fa-ml